Skip to content

Commit 9250059

Browse files
committed
feat: Clear chat log
1 parent ad44d4d commit 9250059

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

ui/src/api/chat/chat.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,17 @@ const deleteChat: (chat_id: string, loading?: Ref<boolean>) => Promise<Result<an
274274
chat_id,
275275
loading,
276276
) => {
277-
return del(`historical_conversation/${chat_id}`, loading)
277+
return del(`historical_conversation/${chat_id}`,undefined,undefined ,loading)
278+
}
279+
/**
280+
*
281+
* @param loading
282+
* @returns
283+
*/
284+
const clearChat: (loading?: Ref<boolean>) => Promise<Result<any>> = (
285+
loading
286+
) => {
287+
return del(`historical_conversation/clear`,undefined,undefined, loading)
278288
}
279289
/**
280290
*
@@ -344,6 +354,7 @@ export default {
344354
textToSpeech,
345355
speechToText,
346356
deleteChat,
357+
clearChat,
347358
modifyChat,
348359
postUploadFile,
349360
}

ui/src/views/chat/component/HistoryPanel.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@
4141
<span>{{ $t('chat.history') }}</span>
4242
<el-tooltip effect="dark" :content="$t('chat.clearChat')" placement="right">
4343
<!-- // TODO: 清空 -->
44-
<el-button text>
44+
<el-button
45+
text
46+
@click="clearChat"
47+
>
4548
<el-icon>
4649
<Delete />
4750
</el-icon>
@@ -184,7 +187,7 @@ const props = defineProps<{
184187
currentChatId: string
185188
isPcCollapse?: boolean
186189
}>()
187-
const emit = defineEmits(['newChat', 'clickLog', 'deleteLog', 'refreshFieldTitle'])
190+
const emit = defineEmits(['newChat', 'clickLog', 'deleteLog', 'refreshFieldTitle','clearChat'])
188191
189192
const EditTitleDialogRef = ref()
190193
@@ -205,6 +208,10 @@ const deleteChatLog = (row: any) => {
205208
emit('deleteLog', row)
206209
}
207210
211+
const clearChat = () => {
212+
emit('clearChat')
213+
}
214+
208215
function editLogTitle(row: any) {
209216
EditTitleDialogRef.value.open(row, props.applicationDetail.id)
210217
}

ui/src/views/chat/pc/index.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
@new-chat="newChat"
3030
@clickLog="clickListHandle"
3131
@delete-log="deleteLog"
32+
@clear-chat="clearChat"
3233
@refreshFieldTitle="refreshFieldTitle"
3334
:isPcCollapse="isPcCollapse"
3435
>
@@ -230,7 +231,12 @@ import ParagraphSourceContent
230231
import ParagraphDocumentContent
231232
from '@/components/ai-chat/component/knowledge-source-component/ParagraphDocumentContent.vue'
232233
import HistoryPanel from '@/views/chat/component/HistoryPanel.vue'
234+
<<<<<<< Updated upstream
233235
import {cloneDeep} from 'lodash'
236+
=======
237+
import { cloneDeep } from 'lodash'
238+
import { ElMessage } from 'element-plus'
239+
>>>>>>> Stashed changes
234240
235241
useResize()
236242
@@ -325,6 +331,19 @@ function deleteLog(row: any) {
325331
})
326332
}
327333
334+
335+
function clearChat() {
336+
chatAPI.clearChat(left_loading, ).then(() => {
337+
currentChatId.value = 'new'
338+
currentChatName.value = t('chat.createChat')
339+
paginationConfig.value.current_page = 1
340+
paginationConfig.value.total = 0
341+
currentRecordList.value = []
342+
ElMessage.success(t('success'))
343+
getChatLog(applicationDetail.value.id)
344+
})
345+
}
346+
328347
function handleScroll(event: any) {
329348
if (
330349
currentChatId.value !== 'new' &&

0 commit comments

Comments
 (0)