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.resetToDefault") }}
diff --git a/composables/useDialog.ts b/composables/useDialog.ts
index 18f346a..4b47228 100644
--- a/composables/useDialog.ts
+++ b/composables/useDialog.ts
@@ -19,7 +19,7 @@ export function useDialog(type: 'modal' | 'confirm' | 'alert') {
props: {
title: {
type: String,
- default: 'Confirm Action',
+ default: t('global.confirmTitle'),
},
description: {
type: String as PropType,
diff --git a/locales/en-US.json b/locales/en-US.json
index aeb7b91..78cbac3 100644
--- a/locales/en-US.json
+++ b/locales/en-US.json
@@ -90,7 +90,9 @@
"selectInstruction": "Select an Instruction",
"resend": "Resend",
"noModelFound": "No model found",
- "noModelFoundDesc": "Please download a model first."
+ "noModelFoundDesc": "Please download a model first.",
+ "clearBtn": "Clear history messages",
+ "clearConfirmTip": "Are you sure you want to clear all history messages for this conversation?"
},
"settings": {
"ollamaServer": "Ollama Server",
@@ -158,9 +160,10 @@
"userName": "User Name",
"password": "Password",
"streamError": "The browser doesn't support streaming responses.",
- "confirmText": "confirm",
- "cancelText": "cancel",
+ "confirmText": "Confirm",
+ "cancelText": "Cancel",
"selectModel": "Select a model",
- "selectModels": "Select models"
+ "selectModels": "Select models",
+ "confirmTitle": "Confirm action"
}
}
\ No newline at end of file
diff --git a/locales/zh-CN.json b/locales/zh-CN.json
index d0ea591..6b5a910 100644
--- a/locales/zh-CN.json
+++ b/locales/zh-CN.json
@@ -90,7 +90,9 @@
"selectInstruction": "选择指令",
"resend": "重发",
"noModelFound": "没有找到模型",
- "noModelFoundDesc": "请先在模型管理页面下载模型"
+ "noModelFoundDesc": "请先在模型管理页面下载模型",
+ "clearBtn": "清空历史消息",
+ "clearConfirmTip": "确定要清空该对话的所有历史消息吗?"
},
"settings": {
"ollamaServer": "Ollama 服务",
@@ -158,6 +160,7 @@
"userName": "用户名称",
"password": "密码",
"streamError": "您的浏览器不支持流式响应,请使用最新版本的浏览器。",
+ "confirmTitle": "确定操作",
"confirmText": "确定",
"cancelText": "取消",
"selectModel": "选择模型",