diff --git a/frontend/app/generate/page.tsx b/frontend/app/generate/page.tsx index bdca39e..e2a3fa7 100644 --- a/frontend/app/generate/page.tsx +++ b/frontend/app/generate/page.tsx @@ -90,18 +90,6 @@ function GenerateContent() { setIsInitialLoad(false) // 標記初始載入完成 }, [loadAnalysisFromCache]) - // 監聽文本變化,自動清除不匹配的分析結果 - useEffect(() => { - if (!isInitialLoad && textInput !== lastAnalyzedText && sentenceAnalysis) { - // 清除所有分析結果 - setSentenceAnalysis(null) - setSentenceMeaning('') - setGrammarCorrection(null) - setSelectedIdiom(null) - setSelectedWord(null) - console.log('🧹 已清除舊的分析結果,因為文本已改變') - } - }, [textInput, lastAnalyzedText, isInitialLoad, sentenceAnalysis]) // 處理句子分析 const handleAnalyzeSentence = async () => { @@ -332,6 +320,30 @@ function GenerateContent() { {sentenceAnalysis && (
+ {/* 狀態指示器 */} +
+
+ + {textInput.trim() !== lastAnalyzedText ? + '⚠️ 顯示的是舊文本的分析結果' : + '✅ 當前文本的分析結果' + } + + + 「{lastAnalyzedText}」 + + {textInput.trim() !== lastAnalyzedText && ( + + 點擊「分析句子」查看新文本的分析 + + )} +
+
+ {/* 語法修正面板 */} {grammarCorrection && grammarCorrection.hasErrors && (
@@ -397,7 +409,7 @@ function GenerateContent() {
- {textInput.split(/(\s+)/).map((token, index) => { + {lastAnalyzedText.split(/(\s+)/).map((token, index) => { const cleanToken = token.replace(/[^\w']/g, '') if (!cleanToken || /^\s+$/.test(token)) { return {token} @@ -425,7 +437,7 @@ function GenerateContent() {