From 27317f4d322d588fd1e1854af89d80dcc1beea5e Mon Sep 17 00:00:00 2001 From: thzxx Date: Fri, 3 Apr 2026 12:33:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=81=9C=E6=AD=A2=E6=97=B6=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E5=86=85=E5=AE=B9=E5=8F=98=20undefined=20=E2=80=94=20?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E4=BD=9C=E7=94=A8=E5=9F=9F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit assistantContent/thinkContent/modelName 声明在 try 块内, catch 中访问不到导致全部为 undefined。 将声明提到 try 外部,catch 正常访问已生成内容。 --- js/components/input-area.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/components/input-area.js b/js/components/input-area.js index 7b8ec92..58ef29e 100644 --- a/js/components/input-area.js +++ b/js/components/input-area.js @@ -196,12 +196,13 @@ export async function sendMessage() { const systemPrompt = state.get(KEYS.SYSTEM_PROMPT); const numCtx = state.get(KEYS.NUM_CTX, 24576); - try { - let assistantContent = ''; - let thinkContent = ''; - let finalStats = null; - let modelName = ''; + // 流式回复状态变量(声明在 try 外,catch 中也需要访问) + let assistantContent = ''; + let thinkContent = ''; + let finalStats = null; + let modelName = ''; + try { const apiMessages = currentSession.messages.map(m => ({ role: m.role, content: m.content || '',