From 989e92ce85249e13889c90b192a2dfbbd3292b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=84=AD=E6=B2=9B=E8=BB=92?= Date: Wed, 24 Sep 2025 14:41:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=BE=A9=E8=A9=9E=E5=8D=A1?= =?UTF-8?q?=E9=A0=81=E9=9D=A2=20TypeScript=20=E9=8C=AF=E8=AA=A4=E4=B8=A6?= =?UTF-8?q?=E6=B8=85=E7=90=86=E5=86=97=E9=A4=98=E4=BB=A3=E7=A2=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔧 TypeScript 錯誤修復: - 移除循環引用:刪除 `type Flashcard = Flashcard` 重複定義 - 清理 import 衝突:直接使用從 flashcards.ts 導入的 Flashcard 型別 - 移除未使用變數:刪除 mockFlashcards 假資料定義 - 清理冗餘型別:移除不需要的 CardSet 型別定義 🧹 代碼清理: - 完全移除假資料依賴,現在純粹使用真實 API - 簡化型別結構,避免不必要的型別重複定義 - 提升代碼可維護性和類型安全性 現在詞卡頁面沒有 TypeScript 錯誤,所有功能正常運作。 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- frontend/app/flashcards/page.tsx | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/frontend/app/flashcards/page.tsx b/frontend/app/flashcards/page.tsx index 4d8e2d7..21fcc98 100644 --- a/frontend/app/flashcards/page.tsx +++ b/frontend/app/flashcards/page.tsx @@ -9,15 +9,7 @@ import { useToast } from '@/components/Toast' // import { flashcardsService, type CardSet, type Flashcard } from '@/lib/services/flashcards' import { flashcardsService, type Flashcard } from '@/lib/services/flashcards' -// 暫時為了兼容性定義 CardSet 類型 -type CardSet = { - id: string; - name: string; - color: string; -} - -// 使用簡化的 Flashcard 類型 -type Flashcard = Flashcard +// 移除不需要的型別定義,直接使用 import 的 Flashcard 型別 import { useRouter } from 'next/navigation' function FlashcardsContent() { @@ -77,15 +69,7 @@ function FlashcardsContent() { const [showForm, setShowForm] = useState(false) const [editingCard, setEditingCard] = useState(null) - // 添加假資料用於展示CEFR效果 (更新為 Flashcard 格式) - const mockFlashcards: Flashcard[] = [ - { id: 'mock1', word: 'hello', translation: '你好', partOfSpeech: 'interjection', pronunciation: '/həˈloʊ/', masteryLevel: 95, timesReviewed: 15, isFavorite: true, nextReviewDate: '2025-09-21', difficultyLevel: 'A1', definition: 'A greeting word', example: 'Hello, how are you?', createdAt: '2025-09-17', updatedAt: '2025-09-17' }, - { id: 'mock2', word: 'beautiful', translation: '美麗的', partOfSpeech: 'adjective', pronunciation: '/ˈbjuːtɪfəl/', masteryLevel: 78, timesReviewed: 8, isFavorite: false, nextReviewDate: '2025-09-22', difficultyLevel: 'A2', definition: 'Pleasing to look at', example: 'The beautiful sunset', createdAt: '2025-09-16', updatedAt: '2025-09-16' }, - { id: 'mock3', word: 'understand', translation: '理解', partOfSpeech: 'verb', pronunciation: '/ˌʌndərˈstænd/', masteryLevel: 65, timesReviewed: 12, isFavorite: true, nextReviewDate: '2025-09-20', difficultyLevel: 'B1', definition: 'To comprehend', example: 'I understand the concept', createdAt: '2025-09-15', updatedAt: '2025-09-15' }, - { id: 'mock4', word: 'elaborate', translation: '詳細說明', partOfSpeech: 'verb', pronunciation: '/ɪˈlæbərət/', masteryLevel: 45, timesReviewed: 5, isFavorite: false, nextReviewDate: '2025-09-19', difficultyLevel: 'B2', definition: 'To explain in detail', example: 'Please elaborate on your idea', createdAt: '2025-09-14', updatedAt: '2025-09-14' }, - { id: 'mock5', word: 'sophisticated', translation: '精密的', partOfSpeech: 'adjective', pronunciation: '/səˈfɪstɪkeɪtɪd/', masteryLevel: 30, timesReviewed: 3, isFavorite: true, nextReviewDate: '2025-09-18', difficultyLevel: 'C1', definition: 'Highly developed', example: 'A sophisticated system', createdAt: '2025-09-13', updatedAt: '2025-09-13' }, - { id: 'mock6', word: 'ubiquitous', translation: '無處不在的', partOfSpeech: 'adjective', pronunciation: '/juːˈbɪkwɪtəs/', masteryLevel: 15, timesReviewed: 1, isFavorite: false, nextReviewDate: '2025-09-17', difficultyLevel: 'C2', definition: 'Present everywhere', example: 'Smartphones are ubiquitous', createdAt: '2025-09-12', updatedAt: '2025-09-12' } - ] + // 移除假資料,現在完全使用真實 API 資料 // 載入總數統計 const loadTotalCounts = async () => { @@ -233,7 +217,6 @@ function FlashcardsContent() { // 由於後端已處理篩選,直接使用 API 回傳的結果 - const allCards = [...flashcards, ...mockFlashcards] // 保留模擬資料用於展示 const filteredCards = flashcards // 直接使用從 API 取得的已篩選結果 // 清除所有篩選