fix: 停止时消息内容变 undefined — 变量作用域问题

assistantContent/thinkContent/modelName 声明在 try 块内,
catch 中访问不到导致全部为 undefined。
将声明提到 try 外部,catch 正常访问已生成内容。
This commit is contained in:
thzxx
2026-04-03 12:33:02 +08:00
parent f80dd7f390
commit 27317f4d32
+6 -5
View File
@@ -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 || '',