diff --git a/src/api/ai/chat/conversation/index.ts b/src/api/ai/chat/conversation/index.ts
index e1ce0f8d..683646ea 100644
--- a/src/api/ai/chat/conversation/index.ts
+++ b/src/api/ai/chat/conversation/index.ts
@@ -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` })
diff --git a/src/api/ai/chat/message/index.ts b/src/api/ai/chat/message/index.ts
index d2f91579..05b4d804 100644
--- a/src/api/ai/chat/message/index.ts
+++ b/src/api/ai/chat/message/index.ts
@@ -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}`
})
diff --git a/src/views/ai/chat/index.vue b/src/views/ai/chat/index.vue
index f98490e8..5e9f7e55 100644
--- a/src/views/ai/chat/index.vue
+++ b/src/views/ai/chat/index.vue
@@ -59,7 +59,7 @@
角色仓库
-
+
清空未置顶对话
@@ -233,7 +233,7 @@ const {copy} = useClipboard()
const drawer = ref
(false) // 角色仓库抽屉
const searchName = ref('') // 查询的内容
const inputTimeout = ref() // 处理输入中回车的定时器
-const conversationId = ref(-1) // 选中的对话编号
+const conversationId = ref(null) // 选中的对话编号
const conversationInProgress = ref(false) // 对话进行中
const conversationInAbortController = ref() // 对话进行中 abort 控制器(控制 stream 对话)
@@ -247,7 +247,7 @@ const isComposing = ref(false) // 判断用户是否在输入
/** chat message 列表 */
// defineOptions({ name: 'chatMessageList' })
const list = ref([]) // 列表的数据
-const useConversation = ref() // 使用的 Conversation
+const useConversation = ref(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 () => {
// 设置当前对话