From bf127782f4043d9921b0a1d4f71110d17eb66e71 Mon Sep 17 00:00:00 2001 From: TU Date: Mon, 6 Jul 2026 21:07:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/VocabCards.tsx | 126 ++++++++++++++++------------------ 1 file changed, 61 insertions(+), 65 deletions(-) diff --git a/src/components/VocabCards.tsx b/src/components/VocabCards.tsx index 388cb8e..ee6d01a 100644 --- a/src/components/VocabCards.tsx +++ b/src/components/VocabCards.tsx @@ -4,7 +4,7 @@ */ import React, { useEffect, useState } from 'react'; -import { BookOpen, ChevronDown, Layers3 } from 'lucide-react'; +import { ArrowLeft, BookOpen, Layers3 } from 'lucide-react'; import { apiUrl } from '../api'; interface VocabEntry { @@ -38,7 +38,7 @@ const colorClassFor = (color: string) => { export const VocabCards: React.FC = () => { const [cards, setCards] = useState([]); - const [expandedTerm, setExpandedTerm] = useState(null); + const [selectedCard, setSelectedCard] = useState(null); const [status, setStatus] = useState<'loading' | 'ready' | 'error'>('loading'); useEffect(() => { @@ -68,20 +68,33 @@ export const VocabCards: React.FC = () => { return (
-
+
- 单词卡片 + {selectedCard ? selectedCard.text : '单词卡片'}
-
- 按词合并所有歌词注释 + {!selectedCard && ( +
+ 按词合并所有歌词注释 +
+ )} +
+ {selectedCard ? ( + + ) : ( +
+ {cards.length} 词
-
-
- {cards.length} 词 -
+ )}
{status === 'loading' && ( @@ -102,65 +115,48 @@ export const VocabCards: React.FC = () => {
)} -
- {cards.map((card) => { - const isExpanded = expandedTerm === card.normalizedText; - return ( -
- - -
- {card.latestComment || '无释义内容'}
+ ))} +
+
+ )} - {isExpanded && ( -
- {card.entries.map((entry, index) => ( -
-
- - {entry.documentTitle} · 行 {entry.lineNumber} -
-
- {entry.lineText} -
-
- {entry.comment} -
-
- ))} -
- )} - - ); - })} -
+ {status === 'ready' && !selectedCard && ( +
+ {cards.map((card) => ( + + ))} +
+ )} );