From 0ec12aa0ca4e2cf33fb5acf380db86bd1668f643 Mon Sep 17 00:00:00 2001 From: Shuming Liu Date: Tue, 26 May 2026 10:45:32 +0800 Subject: [PATCH] fixed a bug --- src/components/VocabularyStudy.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/VocabularyStudy.tsx b/src/components/VocabularyStudy.tsx index ad8864d..a1d9b87 100644 --- a/src/components/VocabularyStudy.tsx +++ b/src/components/VocabularyStudy.tsx @@ -642,13 +642,17 @@ const VocabularyStudy: React.FC = () => { answerSubmittingRef.current = false; return; } - if (testType === 'multiple-choice' && options.length > 0 && options.every(option => option.token !== userAnswer)) { + const normalizedUserAnswer = userAnswer.trim(); + if (!normalizedUserAnswer) { + answerSubmittingRef.current = false; + return; + } + if (testType === 'multiple-choice' && options.length > 0 && options.every(option => option.token !== normalizedUserAnswer)) { answerSubmittingRef.current = false; message.warning('请选择一个选项后再提交'); return; } const submittedAt = Date.now(); - const normalizedUserAnswer = userAnswer.trim(); const answerProof = buildAnswerProof( testAttemptId, currentQuestion.questionToken, @@ -1411,6 +1415,7 @@ const VocabularyStudy: React.FC = () => { style={{ marginBottom: 15, userSelect: 'none', WebkitUserSelect: 'none' }} onPressEnter={e => { e.stopPropagation(); + if (!userAnswer.trim() || showAnswer) return; submitAnswer(); }} autoFocus @@ -1444,7 +1449,7 @@ const VocabularyStudy: React.FC = () => {