feat: 优化多会话内容

This commit is contained in:
ChenZhaoYu
2023-02-14 15:56:44 +08:00
parent 701ef0e6e1
commit cf8e2dd7b6
3 changed files with 37 additions and 14 deletions

View File

@@ -16,15 +16,16 @@ export const useHistoryStore = defineStore('history-store', {
},
},
actions: {
addChat(data: Chat.Chat) {
addChat(data: Chat.Chat, uuid: number | null = null) {
if (this.active === null) {
this.historyChat.push({ title: data.message, isEdit: false, data: [data] })
this.active = this.historyChat.length - 1
}
else {
if (this.historyChat[this.active].title === '')
this.historyChat[this.active].title = data.message
this.historyChat[this.active].data.push(data)
const active = uuid !== null ? uuid : this.active
if (this.historyChat[active].title === '')
this.historyChat[active].title = data.message
this.historyChat[active].data.push(data)
}
setLocalHistory(this.$state)
},