【优化】增加对话,切换message

This commit is contained in:
cherishsince 2024-05-16 15:09:20 +08:00
parent 36beffe140
commit 9c370f729a

View File

@ -261,8 +261,11 @@ const createConversation = async () => {
} }
const changeConversation = (id: number) => { const changeConversation = (id: number) => {
//
conversationId.value = id conversationId.value = id
// TODO // TODO
// message
messageList()
} }
/** 更新聊天会话的标题 */ /** 更新聊天会话的标题 */
@ -535,10 +538,10 @@ const getChatConversationList = async () => {
conversationList.value = await ChatConversationApi.getChatConversationMyList() conversationList.value = await ChatConversationApi.getChatConversationMyList()
// //
if (conversationList.value.length === 0) { if (conversationList.value.length === 0) {
conversationId.value = 0 conversationId.value = null
// TODO list.value = []
} else { } else {
if (conversationId.value === 0) { if (conversationId.value === null) {
conversationId.value = conversationList.value[0].id conversationId.value = conversationList.value[0].id
changeConversation(conversationList.value[0].id) changeConversation(conversationList.value[0].id)
} }
@ -607,16 +610,30 @@ const handleRoleRepository = async () => {
// //
const handleClearConversation = async () => { const handleClearConversation = async () => {
await ChatConversationApi.deleteMyAllExceptPinned() ElMessageBox.confirm(
ElMessage({ '确认后对话会全部清空,置顶的对话除外。',
message: '操作成功!', '确认提示',
type: 'success' {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(async () => {
await ChatConversationApi.deleteMyAllExceptPinned()
ElMessage({
message: '操作成功!',
type: 'success'
})
//
useConversation.value = null
conversationId.value = null
list.value = []
//
await getChatConversationList()
})
.catch(() => {
}) })
//
useConversation.value = null
conversationId.value = null
//
await getChatConversationList()
} }