From 09c03abf519223416f0f0e6d77ad0eedcf1cbbb6 Mon Sep 17 00:00:00 2001 From: cherishsince Date: Fri, 24 May 2024 16:11:16 +0800 Subject: [PATCH 1/3] =?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=E5=A2=9E=E5=8A=A0=E5=9B=9E=E7=AD=94=E4=B8=AD?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E8=83=BD=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/ai/chat/index.vue | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/views/ai/chat/index.vue b/src/views/ai/chat/index.vue index d9a44df1..09300689 100644 --- a/src/views/ai/chat/index.vue +++ b/src/views/ai/chat/index.vue @@ -102,7 +102,7 @@ import MessageLoading from './MessageLoading.vue' import MessageNewChat from './MessageNewChat.vue' import {ChatMessageApi, ChatMessageVO} from '@/api/ai/chat/message' import {ChatConversationApi, ChatConversationVO} from '@/api/ai/chat/conversation' -import { getUserProfile, ProfileVO } from '@/api/system/user/profile' +import {getUserProfile, ProfileVO} from '@/api/system/user/profile' import {useClipboard} from '@vueuse/core' import ChatConversationUpdateForm from "@/views/ai/chat/components/ChatConversationUpdateForm.vue"; import {Download, Top} from "@element-plus/icons-vue"; @@ -339,8 +339,14 @@ const doSendStream = async (userMessage: ChatMessageVO) => { userMessage.content, conversationInAbortController.value, enableContext.value, - async (message) => { - const data = JSON.parse(message.data) // TODO 芋艿:类型处理; + async (res) => { + console.log('res', res) + const { code, data, msg } = JSON.parse(res.data) + if (code !== 0) { + message.alert(`对话异常! ${msg}`) + return + } + // 如果内容为空,就不处理。 if (data.receive.content === '') { return @@ -361,14 +367,13 @@ const doSendStream = async (userMessage: ChatMessageVO) => { await scrollToBottom() }, (error) => { - console.log('onError') + message.alert(`对话异常! ${error}`) // 标记对话结束 conversationInProgress.value = false // 结束 stream 对话 conversationInAbortController.value.abort() }, () => { - console.log('onClose') // 标记对话结束 conversationInProgress.value = false // 结束 stream 对话 @@ -520,6 +525,10 @@ const handlerNewChat = async () => { * 删除 message */ const handlerMessageDelete = async () => { + if (conversationInProgress.value) { + message.alert('回答中,不能删除!') + return + } // 刷新 message await getMessageList() } From 63693f7a836d858bbf25cd1e665eb643d3efc87c Mon Sep 17 00:00:00 2001 From: cherishsince Date: Fri, 24 May 2024 16:42:27 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E3=80=90=E8=A7=A3=E5=86=B3todo=E3=80=91cha?= =?UTF-8?q?t=20=E9=BB=98=E8=AE=A4=E9=80=89=E4=B8=AD=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/Conversation.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/views/ai/chat/Conversation.vue b/src/views/ai/chat/Conversation.vue index 4b2d60ef..3c0af731 100644 --- a/src/views/ai/chat/Conversation.vue +++ b/src/views/ai/chat/Conversation.vue @@ -387,6 +387,8 @@ onMounted(async () => { // 首次默认选中第一个 if (conversationList.value.length) { activeConversationId.value = conversationList.value[0].id + // 回调 onConversationClick + await emits('onConversationClick', conversationList.value[0]) } } }) From 24c459557dfd8bbf0e7d13840c049809b303f872 Mon Sep 17 00:00:00 2001 From: cherishsince Date: Fri, 24 May 2024 16:50:55 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E3=80=90=E8=A7=A3=E5=86=B3todo=E3=80=91=20?= =?UTF-8?q?=E6=B8=85=E7=A9=BA=E8=BE=93=E5=85=A5=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/ai/chat/index.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/views/ai/chat/index.vue b/src/views/ai/chat/index.vue index 09300689..353733e6 100644 --- a/src/views/ai/chat/index.vue +++ b/src/views/ai/chat/index.vue @@ -475,6 +475,8 @@ const handleConversationClick = async (conversation: ChatConversationVO) => { await getMessageList() // 滚动底部 scrollToBottom(true) + // 清空输入框 + prompt.value = '' return true }