diff --git a/components/Chat.vue b/components/Chat.vue index ba9b9c6..437d5a8 100644 --- a/components/Chat.vue +++ b/components/Chat.vue @@ -223,6 +223,9 @@ function onOpenSettings() { instructionInfo.value = data.instructionInfo emits('changeSettings', updatedSessionInfo) + }, + onClear: () => { + messages.value = [] } }) } diff --git a/components/ChatSettings.vue b/components/ChatSettings.vue index b4cae16..421eaf1 100644 --- a/components/ChatSettings.vue +++ b/components/ChatSettings.vue @@ -13,9 +13,11 @@ const props = defineProps<{ sessionId: number onClose: () => void onUpdated?: (data: UpdatedOptions) => void + onClear?: () => void }>() const { t } = useI18n() +const confirm = useDialog('confirm') const defaultConfig = { instructionId: 0, @@ -44,6 +46,16 @@ onMounted(() => { }) }) +function onClearHistory() { + props.onClose() + nextTick(() => { + confirm(t('chat.clearConfirmTip')).then(async () => { + await clientDB.chatHistories.where('sessionId').equals(props.sessionId).delete() + props.onClear?.() + }).catch(noop) + }) +} + async function onSave() { const knowledgeBaseInfo = knowledgeBases.find(el => el.id === state.knowledgeBaseId) const instructionInfo = instructions.find(el => el.id === state.instructionId) @@ -101,6 +113,9 @@ async function onReset() { +
+ {{ t('chat.clearBtn') }} +