diff --git a/ui/src/api/chat/chat.ts b/ui/src/api/chat/chat.ts index 53241da51..81ea72ac6 100644 --- a/ui/src/api/chat/chat.ts +++ b/ui/src/api/chat/chat.ts @@ -274,7 +274,17 @@ const deleteChat: (chat_id: string, loading?: Ref) => Promise { - return del(`historical_conversation/${chat_id}`, loading) + return del(`historical_conversation/${chat_id}`,undefined,undefined ,loading) +} +/** + * + * @param loading + * @returns + */ +const clearChat: (loading?: Ref) => Promise> = ( + loading +) => { + return del(`historical_conversation/clear`,undefined,undefined, loading) } /** * @@ -344,6 +354,7 @@ export default { textToSpeech, speechToText, deleteChat, + clearChat, modifyChat, postUploadFile, } diff --git a/ui/src/views/chat/component/HistoryPanel.vue b/ui/src/views/chat/component/HistoryPanel.vue index a1cebb510..c504be346 100644 --- a/ui/src/views/chat/component/HistoryPanel.vue +++ b/ui/src/views/chat/component/HistoryPanel.vue @@ -41,7 +41,10 @@ {{ $t('chat.history') }} - + @@ -184,7 +187,7 @@ const props = defineProps<{ currentChatId: string isPcCollapse?: boolean }>() -const emit = defineEmits(['newChat', 'clickLog', 'deleteLog', 'refreshFieldTitle']) +const emit = defineEmits(['newChat', 'clickLog', 'deleteLog', 'refreshFieldTitle','clearChat']) const EditTitleDialogRef = ref() @@ -205,6 +208,10 @@ const deleteChatLog = (row: any) => { emit('deleteLog', row) } +const clearChat = () => { + emit('clearChat') +} + function editLogTitle(row: any) { EditTitleDialogRef.value.open(row, props.applicationDetail.id) } diff --git a/ui/src/views/chat/pc/index.vue b/ui/src/views/chat/pc/index.vue index 74316998a..da3092d95 100644 --- a/ui/src/views/chat/pc/index.vue +++ b/ui/src/views/chat/pc/index.vue @@ -29,6 +29,7 @@ @new-chat="newChat" @clickLog="clickListHandle" @delete-log="deleteLog" + @clear-chat="clearChat" @refreshFieldTitle="refreshFieldTitle" :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) { if ( currentChatId.value !== 'new' &&