Commit 5c90ccc6 authored by ligaowei's avatar ligaowei

fix(chat): 优化完成事件处理逻辑,避免重复更新消息内容

- 注释后端completion事件中发送完整内容的代码,避免重复发送
- 前端收到完成事件时,不再更新消息内容,避免覆盖实时token流更新
- 前端调整完成事件处理逻辑,仅更新流状态和加载状态
- 清理完成事件时的超时计时器,确保流正确结束
parent f7888179
......@@ -93,9 +93,9 @@ public class CompletionHandlerService {
// 发送完成事件
try {
// 发送完整内容作为最后一个token
if (fullContent != null && !fullContent.isEmpty()) {
eventService.sendTokenEvent(emitter, fullContent);
}
// if (fullContent != null && !fullContent.isEmpty()) {
// eventService.sendTokenEvent(emitter, fullContent);
// }
// 发送完成信号
emitter.send("[DONE]");
} catch (Exception e) {
......
......@@ -516,11 +516,8 @@ const processSSELine = async (
// 收到完成事件,清除超时计时器
clearStreamTimeout();
console.log("[SSE完成事件]", data);
// 如果有完整文本内容,更新消息内容
if (data.fullText) {
messages.value[aiMessageIndex].content = data.fullText;
}
// 注意:不在此处设置消息内容,因为token流已经实时更新了内容
// 只设置流状态和加载状态
messages.value[aiMessageIndex].isStreaming = false;
isLoading.value = false;
return true; // 返回true表示流已完成
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment