if (userInput.toLowerCase().trim() === currentWord.word.toLowerCase().trim()) {
handleNext();
} else {
+ setUserInput(""); // 清空闪记输入框,确保回到闪记时为空
setPhase('correction');
setCorrectionInput("");
// 错误时读一遍正确发音提醒
}
};
+ // 抄写正确后回到闪记模式重试
+ const retryFlashcard = () => {
+ setUserInput("");
+ setPhase('flashcard');
+ };
+
if (!currentWord) return <div className="loading">加载中...</div>;
// 阻止复制/剪切/粘贴/右键,防止单词被复制后粘贴作弊
onChange={(e) => setCorrectionInput(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter' && correctionInput === currentWord.word) {
- setPhase('flashcard');
+ retryFlashcard();
}
}}
placeholder="请在此抄写..."
{...inputProps}
/>
{correctionInput === currentWord.word && (
- <button className="action-btn" onClick={() => setPhase('flashcard')}>
+ <button className="action-btn" onClick={retryFlashcard}>
重新尝试 (Enter)
</button>
)}
setTotalCount(shuffled.length);
setPhase('testing');
setUserInput("");
+ setCopyInput("");
setIsRetesting(false);
}, [words]);
if (currentIndex + 1 < queue.length) {
setCurrentIndex(prev => prev + 1);
setUserInput("");
+ setCopyInput("");
setPhase('testing');
} else {
// 本轮结束
setCurrentIndex(0);
setTotalCount(retestWords.length);
setUserInput("");
+ setCopyInput("");
setPhase('testing');
setIsRetesting(true);
}, [wrongQueue]);