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)