【增加】清空 Chat 对话

This commit is contained in:
cherishsince 2024-05-16 12:09:39 +08:00
parent f21991f4fc
commit 36beffe140
3 changed files with 28 additions and 5 deletions

View File

@ -42,6 +42,11 @@ export const ChatConversationApi = {
return await request.delete({ url: `/ai/chat/conversation/delete-my?id=${id}` })
},
// 删除【我的】所有对话,置顶除外
deleteMyAllExceptPinned: async () => {
return await request.delete({ url: `/ai/chat/conversation/delete-my-all-except-pinned` })
},
// 获得【我的】聊天会话列表
getChatConversationMyList: async () => {
return await request.get({ url: `/ai/chat/conversation/my-list` })

View File

@ -25,7 +25,7 @@ export interface ChatMessageSendVO {
// AI chat 聊天
export const ChatMessageApi = {
// 消息列表
messageList: async (conversationId: number) => {
messageList: async (conversationId: number | null) => {
return await request.get({
url: `/ai/chat/message/list-by-conversation-id?conversationId=${conversationId}`
})

View File

@ -59,7 +59,7 @@
<Icon icon="ep:user"/>
<el-text size="small">角色仓库</el-text>
</div>
<div>
<div @click="handleClearConversation">
<Icon icon="ep:delete"/>
<el-text size="small">清空未置顶对话</el-text>
</div>
@ -233,7 +233,7 @@ const {copy} = useClipboard()
const drawer = ref<boolean>(false) //
const searchName = ref('') //
const inputTimeout = ref<any>() //
const conversationId = ref<number>(-1) //
const conversationId = ref<number | null>(null) //
const conversationInProgress = ref(false) //
const conversationInAbortController = ref<any>() // abort ( stream )
@ -247,7 +247,7 @@ const isComposing = ref(false) // 判断用户是否在输入
/** chat message 列表 */
// defineOptions({ name: 'chatMessageList' })
const list = ref<ChatMessageVO[]>([]) //
const useConversation = ref<ChatConversationVO>() // 使 Conversation
const useConversation = ref<ChatConversationVO | null>(null) // 使 Conversation
/** 新建对话 */
const createConversation = async () => {
@ -521,7 +521,10 @@ const onPromptInput = (event) => {
}, 400)
}
const getConversation = async (conversationId: number) => {
const getConversation = async (conversationId: number | null) => {
if (!conversationId) {
return
}
//
useConversation.value = await ChatConversationApi.getChatConversationMy(conversationId)
console.log('useConversation.value', useConversation.value)
@ -602,6 +605,21 @@ const handleRoleRepository = async () => {
drawer.value = !drawer.value
}
//
const handleClearConversation = async () => {
await ChatConversationApi.deleteMyAllExceptPinned()
ElMessage({
message: '操作成功!',
type: 'success'
})
//
useConversation.value = null
conversationId.value = null
//
await getChatConversationList()
}
/** 初始化 **/
onMounted(async () => {
//