【解决todo】AI Chat 增加清理 message

This commit is contained in:
cherishsince
2024-05-22 09:57:46 +08:00
parent d603f1edd0
commit 561d60bccd
3 changed files with 28 additions and 3 deletions

View File

@ -19,7 +19,9 @@
<span v-html="activeConversation?.modelName"></span>
<Icon icon="ep:setting" style="margin-left: 10px"/>
</el-button>
<el-button size="small" :icon="User" class="btn" />
<el-button size="small" class="btn" @click="handlerMessageClear">
<img src="@/assets/ai/clear.svg" style="height: 14px;" />
</el-button>
<el-button size="small" :icon="Download" class="btn" />
<el-button size="small" :icon="Top" class="btn" @click="handlerGoTop" />
</div>
@ -93,7 +95,7 @@ import {ChatMessageApi, ChatMessageVO} from '@/api/ai/chat/message'
import {ChatConversationApi, ChatConversationVO} from '@/api/ai/chat/conversation'
import {useClipboard} from '@vueuse/core'
import ChatConversationUpdateForm from "@/views/ai/chat/components/ChatConversationUpdateForm.vue";
import {Download, Top, User} from "@element-plus/icons-vue";
import {Download, Top} from "@element-plus/icons-vue";
const route = useRoute() // 路由
const message = useMessage() // 消息弹窗
@ -488,6 +490,22 @@ const handlerGoTop = async () => {
await messageRef.value.handlerGoTop()
}
/**
* message 清除
*/
const handlerMessageClear = async () => {
if (!activeConversationId.value) {
return
}
// 确认提示
await message.delConfirm("确认清空对话消息?")
// 清空对话
await ChatMessageApi.deleteByConversationId(activeConversationId.value as string)
// 刷新 message 列表
await getMessageList()
}
/** 初始化 **/
onMounted(async () => {