From d2ae2c4f54da39e468022c41c49b2b6c517fb6b9 Mon Sep 17 00:00:00 2001 From: ChenZhaoYu <790348264@qq.com> Date: Tue, 14 Feb 2023 16:21:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BE=A7=E8=BE=B9?= =?UTF-8?q?=E4=BC=9A=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/business/Chat/layout/sider/List.vue | 5 +++-- src/components/business/Chat/layout/sider/index.vue | 2 +- src/store/modules/history/index.ts | 11 +++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/business/Chat/layout/sider/List.vue b/src/components/business/Chat/layout/sider/List.vue index 1a4e797..000ff96 100644 --- a/src/components/business/Chat/layout/sider/List.vue +++ b/src/components/business/Chat/layout/sider/List.vue @@ -31,10 +31,11 @@ function handleEnter(index: number, isEdit: boolean, event: KeyboardEvent) {
- +
diff --git a/src/components/business/Chat/layout/sider/index.vue b/src/components/business/Chat/layout/sider/index.vue index 3e248ed..b332900 100644 --- a/src/components/business/Chat/layout/sider/index.vue +++ b/src/components/business/Chat/layout/sider/index.vue @@ -12,7 +12,7 @@ const collapsed = ref(appStore.siderCollapsed ?? false) function handleAdd() { historyStore.addHistory({ - title: '', + title: 'New Chat', isEdit: false, data: [], }) diff --git a/src/store/modules/history/index.ts b/src/store/modules/history/index.ts index 29401b6..b2907f8 100644 --- a/src/store/modules/history/index.ts +++ b/src/store/modules/history/index.ts @@ -5,14 +5,17 @@ import { getLocalHistory, setLocalHistory } from './helper' export const useHistoryStore = defineStore('history-store', { state: (): HistoryState => getLocalHistory(), getters: { - getCurrentChat(state): Chat.Chat[] { + getCurrentHistory(state): Chat.HistoryChat { if (state.historyChat.length) { if (state.active === null || state.active >= state.historyChat.length || state.active < 0) state.active = 0 - return state.historyChat[state.active].data ?? [] + return state.historyChat[state.active] ?? { title: '', isEdit: false, data: [] } } state.active = null - return [] + return { title: '', isEdit: false, data: [] } + }, + getCurrentChat(): Chat.Chat[] { + return this.getCurrentHistory.data ?? [] }, }, actions: { @@ -23,7 +26,7 @@ export const useHistoryStore = defineStore('history-store', { } else { const active = uuid !== null ? uuid : this.active - if (this.historyChat[active].title === '') + if (this.historyChat[active].title === 'New Chat') this.historyChat[active].title = data.message this.historyChat[active].data.push(data) }