This commit is contained in:
Sun
2023-11-08 21:53:07 +08:00
commit 211c3071dc
245 changed files with 39293 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
import { defineStore } from 'pinia'
import { defaultState, defaultStatePanelConfig, getLocalState, removeLocalState, setLocalState } from './helper'
import { router } from '@/router'
import type { PanelStateNetworkModeEnum } from '@/enum'
import { get as getUserConfig } from '@/api/panel/userConfig'
export const usePanelState = defineStore('panel', {
state: (): Panel.State => getLocalState() || defaultState(),
getters: {
// getChatHistoryByCurrentActive(state: AiApplet.State) {
// const index = state.history.findIndex(item => item.id === state.active)
// if (index !== -1)
// return state.history[index]
// return null
// },
},
actions: {
setLeftSiderCollapsed(Collapsed: boolean) {
this.leftSiderCollapsed = Collapsed
// this.recordState()
},
setRightSiderCollapsed(Collapsed: boolean) {
this.rightSiderCollapsed = Collapsed
// this.recordState()
},
setNetworkMode(mode: PanelStateNetworkModeEnum) {
this.networkMode = mode
this.recordState()
},
// 获取云端的面板配置
updatePanelConfigByCloud() {
getUserConfig<Panel.userConfig>().then((res) => {
if (res.code === 0)
this.panelConfig = res.data.panel
this.recordState()
})
},
resetPanelConfig() {
this.panelConfig = defaultStatePanelConfig()
},
// async refreshSpaceNoteList(spaceId: string) {
// await getListBySpaceNoteId<Common.ListResponse<SNote.InfoTree[]>>(spaceId).then((res) => {
// this.notesList = res.data.list
// })
// },
async reloadRoute(id?: number) {
// this.recordState()
await router.push({ name: 'AppletDialog', params: { aiAppletId: id } })
},
recordState() {
setLocalState(this.$state)
},
removeState() {
removeLocalState()
},
},
})