From 7203346134d4a8164a33ff4ccf8b66d0d12bcc87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=84=AD=E6=B2=9B=E8=BB=92?= Date: Sat, 20 Sep 2025 04:00:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=E4=BE=8B=E5=8F=A5?= =?UTF-8?q?=E9=87=8D=E7=B5=84=E8=88=87=E4=BE=8B=E5=8F=A5=E5=8F=A3=E8=AA=AA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E8=A8=AD=E8=A8=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 例句重組功能實現 - 實現完整的點擊式單字重組功能 - 添加例句圖片顯示支援 - 創建直觀的重組區域和可用單字區域 - 實現答案檢查和結果回饋系統 - 提供重新開始功能 ## 例句口說功能優化 - 添加例句圖片顯示 - 重新設計為完整例句口說練習 - 使用統一的區塊化布局設計 - 移除單獨的詞彙發音區塊,專注於例句練習 - 調整VoiceRecorder目標為完整例句 ## 技術改進 - 改進拖拉操作為更簡單的點擊操作 - 統一所有測驗模式的視覺設計 - 優化用戶互動體驗和學習流程 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- frontend/app/learn/page.tsx | 201 ++++++++++++++++++++++++++++++------ 1 file changed, 167 insertions(+), 34 deletions(-) diff --git a/frontend/app/learn/page.tsx b/frontend/app/learn/page.tsx index f663898..36ecd86 100644 --- a/frontend/app/learn/page.tsx +++ b/frontend/app/learn/page.tsx @@ -26,6 +26,11 @@ export default function LearnPage() { const [quizOptions, setQuizOptions] = useState(['brought', 'determine', 'achieve', 'consider']) const [cardHeight, setCardHeight] = useState(400) + // Sentence reorder states + const [shuffledWords, setShuffledWords] = useState([]) + const [arrangedWords, setArrangedWords] = useState([]) + const [reorderResult, setReorderResult] = useState(null) + // Refs for measuring card content heights const cardFrontRef = useRef(null) const cardBackRef = useRef(null) @@ -143,6 +148,46 @@ export default function LearnPage() { setShowResult(false); }, [currentCardIndex]) + // Initialize sentence reorder when card changes or mode switches to sentence-reorder + useEffect(() => { + if (mode === 'sentence-reorder') { + const words = currentCard.example.split(/\s+/).filter(word => word.length > 0) + const shuffled = [...words].sort(() => Math.random() - 0.5) + setShuffledWords(shuffled) + setArrangedWords([]) + setReorderResult(null) + } + }, [currentCardIndex, mode, currentCard.example]) + + // Sentence reorder handlers + const handleWordClick = (word: string) => { + // Move word from shuffled to arranged + setShuffledWords(prev => prev.filter(w => w !== word)) + setArrangedWords(prev => [...prev, word]) + setReorderResult(null) + } + + const handleRemoveFromArranged = (word: string) => { + setArrangedWords(prev => prev.filter(w => w !== word)) + setShuffledWords(prev => [...prev, word]) + setReorderResult(null) + } + + const handleCheckReorderAnswer = () => { + const userSentence = arrangedWords.join(' ') + const correctSentence = currentCard.example + const isCorrect = userSentence.toLowerCase().trim() === correctSentence.toLowerCase().trim() + setReorderResult(isCorrect) + } + + const handleResetReorder = () => { + const words = currentCard.example.split(/\s+/).filter(word => word.length > 0) + const shuffled = [...words].sort(() => Math.random() - 0.5) + setShuffledWords(shuffled) + setArrangedWords([]) + setReorderResult(null) + } + const handleFlip = () => { setIsFlipped(!isFlipped) } @@ -891,39 +936,46 @@ export default function LearnPage() { {currentCard.difficulty} + + {/* Example Image */} + {currentCard.exampleImage && ( +
+
+ Example illustration setModalImage(currentCard.exampleImage)} + /> +
+
+ )} +

- 請看例句圖片並大聲說出這個英文單字: + 請看例句圖片並大聲說出完整的例句:

-
-
-

- 中文翻譯:{currentCard.translation} -

-

- 定義:{currentCard.definition} -

-

- 發音:{currentCard.pronunciation} -

-
-

- 請說出這個英文單字: -

-
- -

- 點擊播放聽一遍正確發音 -

+
+ {/* Example Sentence */} +
+

例句

+
+

"{currentCard.example}"

+
+ +
+
+

"{currentCard.exampleTranslation}"

+
{ // 簡化處理:直接顯示結果 - handleSpeakingAnswer(currentCard.word) + handleSpeakingAnswer(currentCard.example) }} />
@@ -1072,25 +1124,106 @@ export default function LearnPage() {
)}

- 請將下方的單字重新排列成正確的句子: + 點擊下方單字,依序重組成正確的句子:

-
-
-

- 詞彙:{currentCard.word} -

-

- 翻譯:{currentCard.exampleTranslation} -

+ {/* Arranged Sentence Area */} +
+

重組區域:

+
+ {arrangedWords.length === 0 ? ( +
+ 點擊下方單字來重組句子 +
+ ) : ( +
+ {arrangedWords.map((word, index) => ( +
handleRemoveFromArranged(word)} + > + {word} + × +
+ ))} +
+ )}
+ {/* Shuffled Words */}
-
- [例句重組題功能開發中...] +

可用單字:

+
+ {shuffledWords.length === 0 ? ( +
+ 所有單字都已使用 +
+ ) : ( +
+ {shuffledWords.map((word, index) => ( + + ))} +
+ )}
+ + {/* Control Buttons */} +
+ {arrangedWords.length > 0 && ( + + )} + +
+ + {/* Result Feedback */} + {reorderResult !== null && ( +
+

+ {reorderResult ? '正確!' : '錯誤!'} +

+ + {!reorderResult && ( +
+

+ 正確答案是:"{currentCard.example}" +

+
+ )} + +
+
+

+ 中文翻譯:{currentCard.exampleTranslation} +

+
+
+
+ )}
{/* Navigation */}