From 45cbfbf002fb780baf1da6aa758cc26b6bd860fe Mon Sep 17 00:00:00 2001 From: Nine9 <57023771+GermMC@users.noreply.github.com> Date: Tue, 7 Mar 2023 18:26:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA=E6=B8=85?= =?UTF-8?q?=E7=A9=BA=E7=9A=84=E5=8A=9F=E8=83=BD=20(#369)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 增加聊天记录导入导出功能 * feat: 添加日期和图标 * perf: 移除触发事件改为 reload --------- Co-authored-by: Nine9 Co-authored-by: ChenZhaoYu <790348264@qq.com> --- src/components/common/Setting/General.vue | 119 +++++++++++++++++----- src/components/common/Setting/index.vue | 11 +- src/locales/en-US.ts | 5 + src/locales/zh-CN.ts | 5 + src/utils/functions/index.ts | 7 ++ 5 files changed, 113 insertions(+), 34 deletions(-) create mode 100644 src/utils/functions/index.ts diff --git a/src/components/common/Setting/General.vue b/src/components/common/Setting/General.vue index d37ed7e..4152b4a 100644 --- a/src/components/common/Setting/General.vue +++ b/src/components/common/Setting/General.vue @@ -1,18 +1,13 @@ @@ -102,25 +146,49 @@ function handleReset() { {{ $t('common.save') }} +
- {{ $t('setting.resetUserInfo') }} - - {{ $t('common.reset') }} + {{ $t('setting.chatHistory') }} + + + + {{ $t('common.export') }} + + + + + + {{ $t('common.import') }} + + + + {{ $t('chat.clearHistoryConfirm') }} +
{{ $t('setting.theme') }}
@@ -128,18 +196,21 @@ function handleReset() { {{ $t('setting.language') }}
+
+ {{ $t('setting.resetUserInfo') }} + + {{ $t('common.reset') }} + +
diff --git a/src/components/common/Setting/index.vue b/src/components/common/Setting/index.vue index dcb1d08..3b27464 100644 --- a/src/components/common/Setting/index.vue +++ b/src/components/common/Setting/index.vue @@ -19,8 +19,6 @@ interface Emit { const active = ref('General') -const reload = ref(false) - const show = computed({ get() { return props.visible @@ -29,13 +27,6 @@ const show = computed({ emit('update:visible', visible) }, }) - -function handleReload() { - reload.value = true - setTimeout(() => { - reload.value = false - }, 0) -}
- +
diff --git a/src/locales/en-US.ts b/src/locales/en-US.ts index b832a08..0766d75 100644 --- a/src/locales/en-US.ts +++ b/src/locales/en-US.ts @@ -3,6 +3,9 @@ export default { delete: 'Delete', save: 'Save', reset: 'Reset', + export: 'Export', + import: 'Import', + clear: 'Clear', yes: 'Yes', no: 'No', noData: 'No Data', @@ -21,6 +24,7 @@ export default { deleteMessage: 'Delete Message', deleteMessageConfirm: 'Are you sure to delete this message?', deleteHistoryConfirm: 'Are you sure to clear this history?', + clearHistoryConfirm: 'Are you sure to clear chat history?', }, setting: { setting: 'Setting', @@ -30,6 +34,7 @@ export default { name: 'Name', description: 'Description', resetUserInfo: 'Reset UserInfo', + chatHistory: 'ChatHistory', theme: 'Theme', language: 'Language', api: 'API', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index d3dc6ea..a500727 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -3,6 +3,9 @@ export default { delete: '删除', save: '保存', reset: '重置', + export: '导出', + import: '导入', + clear: '清空', yes: '是', no: '否', noData: '暂无数据', @@ -21,6 +24,7 @@ export default { deleteMessage: '删除消息', deleteMessageConfirm: '是否删除此消息?', deleteHistoryConfirm: '确定删除此记录?', + clearHistoryConfirm: '确定清空聊天记录?', }, setting: { setting: '设置', @@ -30,6 +34,7 @@ export default { name: '名称', description: '描述', resetUserInfo: '重置用户信息', + chatHistory: '聊天记录', theme: '主题', language: '语言', api: 'API', diff --git a/src/utils/functions/index.ts b/src/utils/functions/index.ts new file mode 100644 index 0000000..debb005 --- /dev/null +++ b/src/utils/functions/index.ts @@ -0,0 +1,7 @@ +export function getCurrentDate() { + const date = new Date() + const day = date.getDate() + const month = date.getMonth() + 1 + const year = date.getFullYear() + return `${year}-${month}-${day}` +}