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) }