【优化】AI 对话增加回答中,不能删除

pull/453/head
cherishsince 2024-05-24 16:11:16 +08:00
parent 8fb54dbb7c
commit 09c03abf51
1 changed files with 14 additions and 5 deletions

View File

@ -102,7 +102,7 @@ import MessageLoading from './MessageLoading.vue'
import MessageNewChat from './MessageNewChat.vue' import MessageNewChat from './MessageNewChat.vue'
import {ChatMessageApi, ChatMessageVO} from '@/api/ai/chat/message' import {ChatMessageApi, ChatMessageVO} from '@/api/ai/chat/message'
import {ChatConversationApi, ChatConversationVO} from '@/api/ai/chat/conversation' 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 {useClipboard} from '@vueuse/core'
import ChatConversationUpdateForm from "@/views/ai/chat/components/ChatConversationUpdateForm.vue"; import ChatConversationUpdateForm from "@/views/ai/chat/components/ChatConversationUpdateForm.vue";
import {Download, Top} from "@element-plus/icons-vue"; import {Download, Top} from "@element-plus/icons-vue";
@ -339,8 +339,14 @@ const doSendStream = async (userMessage: ChatMessageVO) => {
userMessage.content, userMessage.content,
conversationInAbortController.value, conversationInAbortController.value,
enableContext.value, enableContext.value,
async (message) => { async (res) => {
const data = JSON.parse(message.data) // TODO console.log('res', res)
const { code, data, msg } = JSON.parse(res.data)
if (code !== 0) {
message.alert(`对话异常! ${msg}`)
return
}
// //
if (data.receive.content === '') { if (data.receive.content === '') {
return return
@ -361,14 +367,13 @@ const doSendStream = async (userMessage: ChatMessageVO) => {
await scrollToBottom() await scrollToBottom()
}, },
(error) => { (error) => {
console.log('onError') message.alert(`对话异常! ${error}`)
// //
conversationInProgress.value = false conversationInProgress.value = false
// stream // stream
conversationInAbortController.value.abort() conversationInAbortController.value.abort()
}, },
() => { () => {
console.log('onClose')
// //
conversationInProgress.value = false conversationInProgress.value = false
// stream // stream
@ -520,6 +525,10 @@ const handlerNewChat = async () => {
* 删除 message * 删除 message
*/ */
const handlerMessageDelete = async () => { const handlerMessageDelete = async () => {
if (conversationInProgress.value) {
message.alert('回答中,不能删除!')
return
}
// message // message
await getMessageList() await getMessageList()
} }