From: root Date: Thu, 18 Jun 2026 00:12:03 +0000 (+0800) Subject: 输入框禁用粘贴与输入法联想,强制逐字母输入 X-Git-Url: http://acesimba.cloud/gitweb/?a=commitdiff_plain;h=f46aab89798a8af130938c0e0bdd0b0b8ca4c9bc;p=words.git 输入框禁用粘贴与输入法联想,强制逐字母输入 --- diff --git a/frontend/src/components/StudyMode.js b/frontend/src/components/StudyMode.js index e612ec5..66122d1 100644 --- a/frontend/src/components/StudyMode.js +++ b/frontend/src/components/StudyMode.js @@ -102,6 +102,18 @@ function StudyMode() { // 阻止复制/剪切/粘贴/右键,防止单词被复制后粘贴作弊 const blockClipboard = (e) => e.preventDefault(); + // 输入框统一属性:禁用粘贴/右键/输入法联想/自动补全,强制逐字母键盘输入 + const inputProps = { + onPaste: blockClipboard, + onContextMenu: blockClipboard, + onCompositionStart: blockClipboard, // 阻止输入法联想 + autoComplete: "off", + autoCorrect: "off", + autoCapitalize: "off", + spellCheck: false, + inputMode: "latin", + }; + return (

闪记模式:请拼写单词

中文含义:{currentWord.chinese_meaning}

- setUserInput(e.target.value)} onKeyDown={(e) => e.key === 'Enter' && checkFlashcard()} placeholder="输入英文单词..." + {...inputProps} />
@@ -156,7 +169,7 @@ function StudyMode() {

回答错误!正确答案:{currentWord.word}

请抄写一遍以解锁:

- {correctionInput === currentWord.word && (
@@ -305,6 +318,7 @@ function TestMode() { onChange={(e) => setCopyInput(e.target.value)} className={`copy-input ${copyInput === currentWord.word ? 'correct' : ''}`} placeholder="请在此抄写正确单词..." + {...inputProps} /> {copyInput === currentWord.word ? '✅' : '❌'}