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

This commit is contained in:
cherishsince 2024-05-24 16:11:16 +08:00
parent 8fb54dbb7c
commit 09c03abf51

View File

@ -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()
}