From e1d8f5ff56401d7e6d424cc823a28f707fc6b19d Mon Sep 17 00:00:00 2001 From: ChenZhaoYu <790348264@qq.com> Date: Tue, 26 Sep 2023 11:50:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B8=85=E7=A9=BA=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E5=8E=86=E5=8F=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/locales/zh-CN.ts | 2 +- src/store/modules/chat/index.ts | 7 +++++- src/views/chat/layout/sider/index.vue | 32 ++++++++++++++++++++++----- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index a79817e..2e4769b 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -47,7 +47,7 @@ export default { deleteMessage: '删除消息', deleteMessageConfirm: '是否删除此消息?', deleteHistoryConfirm: '确定删除此记录?', - clearHistoryConfirm: '确定清空聊天记录?', + clearHistoryConfirm: '确定清空记录?', preview: '预览', showRawText: '显示原文', }, diff --git a/src/store/modules/chat/index.ts b/src/store/modules/chat/index.ts index 38f3215..44a31fa 100644 --- a/src/store/modules/chat/index.ts +++ b/src/store/modules/chat/index.ts @@ -1,5 +1,5 @@ import { defineStore } from 'pinia' -import { getLocalState, setLocalState } from './helper' +import { defaultState, getLocalState, setLocalState } from './helper' import { router } from '@/router' export const useChatStore = defineStore('chat-store', { @@ -182,6 +182,11 @@ export const useChatStore = defineStore('chat-store', { } }, + clearHistory() { + this.$state = { ...defaultState() } + this.recordState() + }, + async reloadRoute(uuid?: number) { this.recordState() await router.push({ name: 'Chat', params: { uuid } }) diff --git a/src/views/chat/layout/sider/index.vue b/src/views/chat/layout/sider/index.vue index 1cb4ea7..e9434fd 100644 --- a/src/views/chat/layout/sider/index.vue +++ b/src/views/chat/layout/sider/index.vue @@ -1,16 +1,19 @@