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 ( -
{response || '點擊按鈕開始測試'}
- - 這個頁面直接調用API,不經過複雜的狀態管理邏輯。 - 如果這裡能正常顯示結果,說明問題出在其他頁面的前端邏輯。 -
-- 💡 智能標記說明:AI 已識別高學習價值詞彙並標記為免費查詢 -
-- 請確認後端服務正在 http://localhost:5000 運行 -
- )} -- 💡 基於{finalText !== textInput ? '修正後' : '原始'}句子的智能分析: -
-- 💡 使用說明:點擊下方句子中的任何單字,可以立即查看詳細意思。 - 黃色背景表示該單字屬於片語或俚語,會優先顯示片語意思。 -
-{error}
-{result.data.sentenceMeaning.translation}
-{result.data.sentenceMeaning.explanation}
-
- {JSON.stringify(result, null, 2)}
-
-
- {result || '點擊按鈕測試 API 連接'}
-
-
-
- curl -s http://localhost:5000/api/ai/analyze-sentence -X POST -H "Content-Type: application/json" -d '{"inputText":"test"}'
-
- - 💡 使用說明:點擊下方句子中的任何單字,可以立即查看詳細意思。 - 黃色背景表示該單字屬於片語或俚語,會優先顯示片語意思。 -
-