From e7262c04b0a2be1151a76fc18abbdcdc076a406c Mon Sep 17 00:00:00 2001 From: Wenjie Zhang Date: Fri, 25 Apr 2025 09:43:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DAgent=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=9A=84=E6=B6=88=E6=81=AF=E6=8A=A5=E9=94=99=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components/ChatComponent.vue | 41 +++++++------------------ web/src/components/MessageComponent.vue | 9 +++--- 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/web/src/components/ChatComponent.vue b/web/src/components/ChatComponent.vue index b99fe7e7..a4fe2578 100644 --- a/web/src/components/ChatComponent.vue +++ b/web/src/components/ChatComponent.vue @@ -345,40 +345,21 @@ const updateMessage = (info) => { const msg = conv.value.messages.find((msg) => msg.id === info.id); if (msg) { try { - // 只有在 text 不为空时更新 - if (info.content !== null && info.content !== undefined && info.content !== '') { + // 特殊处理:content需要追加而不是替换 + if (info.content != null && info.content !== '') { msg.content += info.content; } - if (info.reasoning_content !== null && info.reasoning_content !== undefined && info.reasoning_content !== '') { - msg.reasoning_content = info.reasoning_content; - } + // 批量处理其他属性,只有当属性值不为null/undefined且不为空字符串时才更新 + const propertiesToUpdate = [ + 'reasoning_content', 'model_name', 'status', 'message', 'showThinking', 'refs', 'meta' + ]; - // 只有在 refs 不为空时更新 - if (info.refs !== null && info.refs !== undefined) { - msg.refs = info.refs; - } - - if (info.model_name !== null && info.model_name !== undefined && info.model_name !== '') { - msg.model_name = info.model_name; - } - - // 只有在 status 不为空时更新 - if (info.status !== null && info.status !== undefined && info.status !== '') { - msg.status = info.status; - } - - if (info.meta !== null && info.meta !== undefined) { - msg.meta = info.meta; - } - - if (info.message !== null && info.message !== undefined) { - msg.message = info.message; - } - - if (info.showThinking !== null && info.showThinking !== undefined) { - msg.showThinking = info.showThinking; - } + propertiesToUpdate.forEach(prop => { + if (info[prop] != null && (typeof info[prop] !== 'string' || info[prop] !== '')) { + msg[prop] = info[prop]; + } + }); scrollToBottom(); } catch (error) { diff --git a/web/src/components/MessageComponent.vue b/web/src/components/MessageComponent.vue index f96cec99..a2ed96bc 100644 --- a/web/src/components/MessageComponent.vue +++ b/web/src/components/MessageComponent.vue @@ -51,9 +51,10 @@ :key="message.id" class="message-md"/> -
- -
+
+ + +
请求错误,请重试。{{ message.message }} @@ -64,8 +65,6 @@ 重新编辑问题
- -