feat: Clear chat log

This commit is contained in:
zhangzhanwei 2025-07-15 14:59:40 +08:00 committed by zhanweizhang7
parent ce213d78af
commit 0434a18905
3 changed files with 34 additions and 3 deletions

View File

@ -274,7 +274,17 @@ const deleteChat: (chat_id: string, loading?: Ref<boolean>) => Promise<Result<an
chat_id, chat_id,
loading, loading,
) => { ) => {
return del(`historical_conversation/${chat_id}`, loading) return del(`historical_conversation/${chat_id}`,undefined,undefined ,loading)
}
/**
*
* @param loading
* @returns
*/
const clearChat: (loading?: Ref<boolean>) => Promise<Result<any>> = (
loading
) => {
return del(`historical_conversation/clear`,undefined,undefined, loading)
} }
/** /**
* *
@ -344,6 +354,7 @@ export default {
textToSpeech, textToSpeech,
speechToText, speechToText,
deleteChat, deleteChat,
clearChat,
modifyChat, modifyChat,
postUploadFile, postUploadFile,
} }

View File

@ -41,7 +41,10 @@
<span>{{ $t('chat.history') }}</span> <span>{{ $t('chat.history') }}</span>
<el-tooltip effect="dark" :content="$t('chat.clearChat')" placement="right"> <el-tooltip effect="dark" :content="$t('chat.clearChat')" placement="right">
<!-- // TODO: --> <!-- // TODO: -->
<el-button text> <el-button
text
@click="clearChat"
>
<el-icon> <el-icon>
<Delete /> <Delete />
</el-icon> </el-icon>
@ -184,7 +187,7 @@ const props = defineProps<{
currentChatId: string currentChatId: string
isPcCollapse?: boolean isPcCollapse?: boolean
}>() }>()
const emit = defineEmits(['newChat', 'clickLog', 'deleteLog', 'refreshFieldTitle']) const emit = defineEmits(['newChat', 'clickLog', 'deleteLog', 'refreshFieldTitle','clearChat'])
const EditTitleDialogRef = ref() const EditTitleDialogRef = ref()
@ -205,6 +208,10 @@ const deleteChatLog = (row: any) => {
emit('deleteLog', row) emit('deleteLog', row)
} }
const clearChat = () => {
emit('clearChat')
}
function editLogTitle(row: any) { function editLogTitle(row: any) {
EditTitleDialogRef.value.open(row, props.applicationDetail.id) EditTitleDialogRef.value.open(row, props.applicationDetail.id)
} }

View File

@ -29,6 +29,7 @@
@new-chat="newChat" @new-chat="newChat"
@clickLog="clickListHandle" @clickLog="clickListHandle"
@delete-log="deleteLog" @delete-log="deleteLog"
@clear-chat="clearChat"
@refreshFieldTitle="refreshFieldTitle" @refreshFieldTitle="refreshFieldTitle"
:isPcCollapse="isPcCollapse" :isPcCollapse="isPcCollapse"
> >
@ -325,6 +326,18 @@ function deleteLog(row: any) {
}) })
} }
function clearChat() {
chatAPI.clearChat(left_loading, ).then(() => {
currentChatId.value = 'new'
currentChatName.value = t('chat.createChat')
paginationConfig.value.current_page = 1
paginationConfig.value.total = 0
currentRecordList.value = []
getChatLog(applicationDetail.value.id)
})
}
function handleScroll(event: any) { function handleScroll(event: any) {
if ( if (
currentChatId.value !== 'new' && currentChatId.value !== 'new' &&