checkAnswer();
} else if (phase === 'feedback' && isCorrect) {
nextWord();
- } else if (phase === 'copy' && copyInput === currentWord.word) {
+ } else if (phase === 'copy' && copyInput.toLowerCase() === currentWord.word.toLowerCase()) {
nextWord();
} else if (phase === 'feedback' && !isCorrect) {
showCopy();
// 阻止复制/剪切/粘贴/右键,防止单词被复制后粘贴作弊
const blockClipboard = (e) => e.preventDefault();
+ // 只保留 ASCII 可见字符并转小写,过滤中文/全角/emoji,同时压制首字母自动大写
+ // 即使中文输入法开启或系统自动大写,输入框也只显示小写英文
+ const sanitize = (s) => s.replace(/[^\x20-\x7E]/g, '').toLowerCase();
+
// 输入框统一属性:强制英文输入、禁用中文输入法/自动大写/自动补全/粘贴
const inputProps = {
type: "text",
<input
ref={inputRef}
value={userInput}
- onChange={(e) => setUserInput(e.target.value)}
+ onChange={(e) => setUserInput(sanitize(e.target.value))}
placeholder="请输入英文单词..."
className="test-input"
{...inputProps}
<input
ref={copyRef}
value={copyInput}
- onChange={(e) => setCopyInput(e.target.value)}
- className={`copy-input ${copyInput === currentWord.word ? 'correct' : ''}`}
+ onChange={(e) => setCopyInput(sanitize(e.target.value))}
+ className={`copy-input ${copyInput.toLowerCase() === currentWord.word.toLowerCase() ? 'correct' : ''}`}
placeholder="请在此抄写正确单词..."
{...inputProps}
/>
- <span className={`copy-check ${copyInput === currentWord.word ? 'ok' : ''}`}>
- {copyInput === currentWord.word ? '✅' : '❌'}
+ <span className={`copy-check ${copyInput.toLowerCase() === currentWord.word.toLowerCase() ? 'ok' : ''}`}>
+ {copyInput.toLowerCase() === currentWord.word.toLowerCase() ? '✅' : '❌'}
</span>
- {copyInput === currentWord.word && (
+ {copyInput.toLowerCase() === currentWord.word.toLowerCase() && (
<button className="action-btn" onClick={nextWord}>
下一词 (Enter)
</button>