From 8d3b8d3b3cefb6b2d2dbb7c2a0542e3fe111c098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9F=A9=E5=BA=86=E4=BC=9F?= <1208669287@qq.com> Date: Wed, 21 May 2025 19:54:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9B=9E=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index/index.vue | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 9fe16ac..4bf10cf 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -99,7 +99,7 @@ @@ -1257,10 +1257,32 @@ function copyText(msg: IMessage) { } } +// 重新发送逻辑 function refreshText() { - const lastUserMsg = historyUserMsgs[historyUserMsgs.length - 1] - lastUserMsg.timestamp = new Date() - sendText(lastUserMsg) + // 获取最后一条用户消息(保留在消息列表中的) + const lastUserMsg = messages.findLast((msg) => msg.role === 'user') + if (!lastUserMsg) return + + // 克隆消息避免污染原始数据 + const clonedMsg = { + ...lastUserMsg, + timestamp: new Date(), + } + + // 发送克隆后的消息 + sendText(clonedMsg) + // // 获取最后一条用户消息(保留在消息列表中的) + // const lastUserMsg = messages.findLast((msg) => msg.role === 'user') + // if (!lastUserMsg) return + + // // 克隆消息避免污染原始数据 + // const newUserMsg = { + // ...lastUserMsg, + // timestamp: new Date(), + // } + // const historyToSend = [...messages, newUserMsg] + // // 发送克隆后的消息 + // sendText(historyToSend) } const knowledgeOpen = ref(false)