From d603f1edd05cd2be822e8ad35a08d0c3c6c2e3d3 Mon Sep 17 00:00:00 2001 From: cherishsince Date: Tue, 21 May 2024 22:44:37 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91AI=20?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E4=B8=AD=EF=BC=8C=E4=B8=8D=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=AF=B9=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/ai/chat/index.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/views/ai/chat/index.vue b/src/views/ai/chat/index.vue index 23e5c237..c4f9aade 100644 --- a/src/views/ai/chat/index.vue +++ b/src/views/ai/chat/index.vue @@ -150,7 +150,6 @@ const textRoll = async () => { textSpeed.value = 10 } - console.log(`diff ${diff} 速度 ${textSpeed.value} `) // console.log('index < fullText.value.length', index < fullText.value.length, conversationInProgress.value) if (index < fullText.value.length) { @@ -341,12 +340,14 @@ const doSendStream = async (userMessage: ChatMessageVO) => { await scrollToBottom() }, (error) => { + console.log('onError') // 标记对话结束 conversationInProgress.value = false // 结束 stream 对话 conversationInAbortController.value.abort() }, () => { + console.log('onClose') // 标记对话结束 conversationInProgress.value = false // 结束 stream 对话 @@ -358,6 +359,7 @@ const doSendStream = async (userMessage: ChatMessageVO) => { } const stopStream = async () => { + console.log('stopStream...') // tip:如果 stream 进行中的 message,就需要调用 controller 结束 if (conversationInAbortController.value) { conversationInAbortController.value.abort() @@ -416,13 +418,24 @@ const handlerTitleSuccess = async () => { * 对话 - 点击 */ const handleConversationClick = async (conversation: ChatConversationVO) => { + // 对话进行中,不允许切换 + if (conversationInProgress.value) { + await message.alert("对话中,不允许切换!") + return false + } + // 更新选中的对话 id activeConversationId.value = conversation.id activeConversation.value = conversation + // 处理进行中的对话 + if (conversationInProgress.value) { + await stopStream() + } // 刷新 message 列表 await getMessageList() // 滚动底部 scrollToBottom(true) + return true } /**