From aca9ec2f7abe0c081701b6eeb20783ac8087038f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=84=AD=E6=B2=9B=E8=BB=92?= Date: Sun, 21 Sep 2025 01:10:50 +0800 Subject: [PATCH] =?UTF-8?q?clean:=20=E7=A7=BB=E9=99=A4=E6=89=80=E6=9C=89?= =?UTF-8?q?=E6=B8=AC=E8=A9=A6=E5=92=8Cdemo=E9=A0=81=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 刪除的頁面: - /demo-v2: 舊版ClickableTextV2測試頁面 - /demo-v3: 包含語法修正的測試版本 - /test: 基礎測試頁面 - /test-api: API測試頁面 - /test-simple: 簡單測試頁面 - /debug: 調試頁面 - /generate-demo: 生成功能的demo版本 清理原因: - 這些頁面都使用已刪除的ClickableText組件 - 功能已整合到正式的/generate頁面 - 沒有任何其他文件引用這些頁面 - 減少約125KB的冗餘代碼 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- frontend/app/debug/page.tsx | 100 ----- frontend/app/demo-v2/page.tsx | 572 --------------------------- frontend/app/demo-v3/page.tsx | 594 ---------------------------- frontend/app/generate-demo/page.tsx | 389 ------------------ frontend/app/test-api/page.tsx | 186 --------- frontend/app/test-simple/page.tsx | 57 --- frontend/app/test/page.tsx | 82 ---- 7 files changed, 1980 deletions(-) delete mode 100644 frontend/app/debug/page.tsx delete mode 100644 frontend/app/demo-v2/page.tsx delete mode 100644 frontend/app/demo-v3/page.tsx delete mode 100644 frontend/app/generate-demo/page.tsx delete mode 100644 frontend/app/test-api/page.tsx delete mode 100644 frontend/app/test-simple/page.tsx delete mode 100644 frontend/app/test/page.tsx diff --git a/frontend/app/debug/page.tsx b/frontend/app/debug/page.tsx deleted file mode 100644 index e8089af..0000000 --- a/frontend/app/debug/page.tsx +++ /dev/null @@ -1,100 +0,0 @@ -'use client' - -import { useState } from 'react' - -export default function DebugPage() { - const [input, setInput] = useState('She felt ashamed of her mistake and apologized.') - const [response, setResponse] = useState('') - const [loading, setLoading] = useState(false) - - const testDirectApi = async () => { - setLoading(true) - setResponse('測試中...') - - try { - console.log('=== 開始API測試 ===') - console.log('輸入:', input) - - const apiResponse = await fetch('http://localhost:5000/api/ai/analyze-sentence', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - inputText: input, - forceRefresh: true - }) - }) - - console.log('API狀態:', apiResponse.status) - - if (!apiResponse.ok) { - throw new Error(`API錯誤: ${apiResponse.status}`) - } - - const data = await apiResponse.json() - console.log('API回應:', data) - - // 直接顯示結果,不經過複雜的狀態管理 - const translation = data.data?.sentenceMeaning?.translation || '無翻譯' - const explanation = data.data?.sentenceMeaning?.explanation || '無解釋' - const highValueWords = data.data?.highValueWords || [] - - setResponse(` -✅ API調用成功 - -📖 翻譯: ${translation} - -📝 解釋: ${explanation} - -⭐ 高價值詞彙: ${JSON.stringify(highValueWords)} - -🔍 完整響應: ${JSON.stringify(data, null, 2)} - `) - } catch (error) { - console.error('API錯誤:', error) - setResponse(`❌ 錯誤: ${error}`) - } finally { - setLoading(false) - } - } - - return ( -
-

🐛 API 調試頁面

- -
-
- - setInput(e.target.value)} - className="w-full p-3 border border-gray-300 rounded-lg" - /> -
- - - -
-

測試結果:

-
{response || '點擊按鈕開始測試'}
-
- -
-

💡 測試說明:

-

- 這個頁面直接調用API,不經過複雜的狀態管理邏輯。 - 如果這裡能正常顯示結果,說明問題出在其他頁面的前端邏輯。 -

-
-
-
- ) -} \ No newline at end of file diff --git a/frontend/app/demo-v2/page.tsx b/frontend/app/demo-v2/page.tsx deleted file mode 100644 index 5ed249f..0000000 --- a/frontend/app/demo-v2/page.tsx +++ /dev/null @@ -1,572 +0,0 @@ -'use client' - -import { useState } from 'react' -import { ClickableTextV2 } from '@/components/ClickableTextV2' - -export default function DemoV2Page() { - const [mode, setMode] = useState<'manual' | 'screenshot'>('manual') - const [textInput, setTextInput] = useState('') - const [isAnalyzing, setIsAnalyzing] = useState(false) - const [showAnalysisView, setShowAnalysisView] = useState(false) - const [sentenceAnalysis, setSentenceAnalysis] = useState(null) - const [sentenceMeaning, setSentenceMeaning] = useState('') - const [usageCount, setUsageCount] = useState(0) - const [isPremium] = useState(false) - - // 模擬分析後的句子資料(新版本) - const mockSentenceAnalysis = { - meaning: "他在我們的會議中提出了這件事,但沒有人同意。這句話表達了在會議中有人提出某個議題或想法,但得不到其他與會者的認同。", - highValueWords: ["brought", "up", "meeting", "agreed"], // 高價值詞彙 - phrasesDetected: [ - { - phrase: "bring up", - words: ["brought", "up"], - colorCode: "#F59E0B" - } - ], - words: { - "he": { - word: "he", - translation: "他", - definition: "Used to refer to a male person or animal", - partOfSpeech: "pronoun", - pronunciation: "/hiː/", - synonyms: ["him", "that man"], - antonyms: [], - isPhrase: false, - isHighValue: false, // 低價值詞彙 - learningPriority: "low", - difficultyLevel: "A1", - costIncurred: 1 - }, - "brought": { - word: "brought", - translation: "帶來、提出", - definition: "Past tense of bring; to take or carry something to a place", - partOfSpeech: "verb", - pronunciation: "/brɔːt/", - synonyms: ["carried", "took", "delivered"], - antonyms: ["removed", "took away"], - isPhrase: true, - isHighValue: true, // 高價值片語 - learningPriority: "high", - phraseInfo: { - phrase: "bring up", - meaning: "提出(話題)、養育", - warning: "在這個句子中,\"brought up\" 是一個片語,意思是\"提出話題\",而不是單純的\"帶來\"", - colorCode: "#F59E0B" - }, - difficultyLevel: "B1", - costIncurred: 0 // 高價值免費 - }, - "this": { - word: "this", - translation: "這個", - definition: "Used to indicate something near or just mentioned", - partOfSpeech: "pronoun", - pronunciation: "/ðɪs/", - synonyms: ["that", "it"], - antonyms: [], - isPhrase: false, - isHighValue: false, // 低價值詞彙 - learningPriority: "low", - difficultyLevel: "A1", - costIncurred: 1 - }, - "thing": { - word: "thing", - translation: "事情、東西", - definition: "An object, fact, or situation", - partOfSpeech: "noun", - pronunciation: "/θɪŋ/", - synonyms: ["object", "matter", "item"], - antonyms: [], - isPhrase: false, - isHighValue: false, // 低價值詞彙 - learningPriority: "low", - difficultyLevel: "A1", - costIncurred: 1 - }, - "up": { - word: "up", - translation: "向上", - definition: "Toward a higher place or position", - partOfSpeech: "adverb", - pronunciation: "/ʌp/", - synonyms: ["upward", "above"], - antonyms: ["down", "below"], - isPhrase: true, - isHighValue: true, // 高價值片語部分 - learningPriority: "high", - phraseInfo: { - phrase: "bring up", - meaning: "提出(話題)、養育", - warning: "\"up\" 在這裡是片語 \"bring up\" 的一部分,不是單獨的\"向上\"的意思", - colorCode: "#F59E0B" - }, - difficultyLevel: "B1", - costIncurred: 0 // 高價值免費 - }, - "during": { - word: "during", - translation: "在...期間", - definition: "Throughout the course or duration of", - partOfSpeech: "preposition", - pronunciation: "/ˈdjʊərɪŋ/", - synonyms: ["throughout", "while"], - antonyms: [], - isPhrase: false, - isHighValue: false, // 低價值詞彙 - learningPriority: "low", - difficultyLevel: "A2", - costIncurred: 1 - }, - "our": { - word: "our", - translation: "我們的", - definition: "Belonging to us", - partOfSpeech: "pronoun", - pronunciation: "/aʊər/", - synonyms: ["ours"], - antonyms: [], - isPhrase: false, - isHighValue: false, // 低價值詞彙 - learningPriority: "low", - difficultyLevel: "A1", - costIncurred: 1 - }, - "meeting": { - word: "meeting", - translation: "會議", - definition: "An organized gathering of people for discussion", - partOfSpeech: "noun", - pronunciation: "/ˈmiːtɪŋ/", - synonyms: ["conference", "assembly", "gathering"], - antonyms: [], - isPhrase: false, - isHighValue: true, // 高價值單字(B2級) - learningPriority: "high", - difficultyLevel: "B2", - costIncurred: 0 // 高價值免費 - }, - "and": { - word: "and", - translation: "和、而且", - definition: "Used to connect words or clauses", - partOfSpeech: "conjunction", - pronunciation: "/ænd/", - synonyms: ["plus", "also"], - antonyms: [], - isPhrase: false, - isHighValue: false, // 低價值詞彙 - learningPriority: "low", - difficultyLevel: "A1", - costIncurred: 1 - }, - "no": { - word: "no", - translation: "沒有", - definition: "Not any; not one", - partOfSpeech: "determiner", - pronunciation: "/nəʊ/", - synonyms: ["none", "zero"], - antonyms: ["some", "any"], - isPhrase: false, - isHighValue: false, // 低價值詞彙 - learningPriority: "low", - difficultyLevel: "A1", - costIncurred: 1 - }, - "one": { - word: "one", - translation: "一個人、任何人", - definition: "A single person or thing", - partOfSpeech: "pronoun", - pronunciation: "/wʌn/", - synonyms: ["someone", "anybody"], - antonyms: ["none", "nobody"], - isPhrase: false, - isHighValue: false, // 低價值詞彙 - learningPriority: "low", - difficultyLevel: "A1", - costIncurred: 1 - }, - "agreed": { - word: "agreed", - translation: "同意", - definition: "Past tense of agree; to have the same opinion", - partOfSpeech: "verb", - pronunciation: "/əˈɡriːd/", - synonyms: ["consented", "accepted", "approved"], - antonyms: ["disagreed", "refused"], - isPhrase: false, - isHighValue: true, // 高價值單字(B1級) - learningPriority: "medium", - difficultyLevel: "B1", - costIncurred: 0 // 高價值免費 - } - } - } - - // 處理句子分析 - const handleAnalyzeSentence = async () => { - if (!textInput.trim()) return - - // 檢查使用次數限制 - if (!isPremium && usageCount >= 5) { - alert('❌ 免費用戶 3 小時內只能分析 5 次句子,請稍後再試或升級到付費版本') - return - } - - setIsAnalyzing(true) - - try { - // 模擬 API 調用 - await new Promise(resolve => setTimeout(resolve, 2000)) - - setSentenceAnalysis(mockSentenceAnalysis.words) - setSentenceMeaning(mockSentenceAnalysis.meaning) - setShowAnalysisView(true) - setUsageCount(prev => prev + 1) // 句子分析扣除1次 - } catch (error) { - console.error('Error analyzing sentence:', error) - alert('分析句子時發生錯誤,請稍後再試') - } finally { - setIsAnalyzing(false) - } - } - - const getHighValueCount = () => { - if (!sentenceAnalysis) return 0 - return Object.values(sentenceAnalysis).filter((word: any) => word.isHighValue).length - } - - const getLowValueCount = () => { - if (!sentenceAnalysis) return 0 - return Object.values(sentenceAnalysis).filter((word: any) => !word.isHighValue).length - } - - return ( -
- {/* Navigation */} - - -
- {!showAnalysisView ? ( -
-

AI 智能生成詞卡 - 高價值標記系統

- - {/* 功能說明 */} -
-

🎯 高價值標記系統特色

-
-
-
-
- 高價值片語 - 免費無限點擊 -
-
-
- 高價值單字 - 免費無限點擊 -
-
-
-
-
- 普通單字 - 點擊扣除 1 次額度 -
-
- - 星號標記 - 高學習價值指標 -
-
-
-
- - {/* Input Mode Selection */} -
-

原始例句類型

-
- - -
-
- - {/* Content Input */} -
-
-

輸入英文文本

-