fix(agent持久化):补充pinia-plugin-persistedstate,优化agent store持久化配置
This commit is contained in:
parent
541b3f40ef
commit
80c74f304b
1615
pnpm-lock.yaml
Normal file
1615
pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load Diff
@ -33,6 +33,7 @@
|
||||
"markmap-view": "^0.18.12",
|
||||
"md-editor-v3": "^5.8.4",
|
||||
"pinia": "^3.0.3",
|
||||
"pinia-plugin-persistedstate": "^4.7.1",
|
||||
"sigma": "^3.0.2",
|
||||
"vue": "^3.5.21",
|
||||
"vue-router": "^4.5.1"
|
||||
|
||||
@ -71,6 +71,9 @@ importers:
|
||||
pinia:
|
||||
specifier: ^3.0.3
|
||||
version: 3.0.3(vue@3.5.21)
|
||||
pinia-plugin-persistedstate:
|
||||
specifier: ^4.7.1
|
||||
version: 4.7.1(pinia@3.0.3(vue@3.5.21))
|
||||
sigma:
|
||||
specifier: ^3.0.2
|
||||
version: 3.0.2(graphology-types@0.24.8)
|
||||
@ -1294,6 +1297,9 @@ packages:
|
||||
deep-is@0.1.4:
|
||||
resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}
|
||||
|
||||
defu@6.1.4:
|
||||
resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==}
|
||||
|
||||
delaunator@5.0.1:
|
||||
resolution: {integrity: sha512-8nvh+XBe96aCESrGOqMp/84b13H9cdKbG5P2ejQCh4d4sK9RL4371qou9drQjMhvnPmhWl5hnmqbEE0fXr9Xnw==}
|
||||
|
||||
@ -1909,6 +1915,20 @@ packages:
|
||||
resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
pinia-plugin-persistedstate@4.7.1:
|
||||
resolution: {integrity: sha512-WHOqh2esDlR3eAaknPbqXrkkj0D24h8shrDPqysgCFR6ghqP/fpFfJmMPJp0gETHsvrh9YNNg6dQfo2OEtDnIQ==}
|
||||
peerDependencies:
|
||||
'@nuxt/kit': '>=3.0.0'
|
||||
'@pinia/nuxt': '>=0.10.0'
|
||||
pinia: '>=3.0.0'
|
||||
peerDependenciesMeta:
|
||||
'@nuxt/kit':
|
||||
optional: true
|
||||
'@pinia/nuxt':
|
||||
optional: true
|
||||
pinia:
|
||||
optional: true
|
||||
|
||||
pinia@3.0.3:
|
||||
resolution: {integrity: sha512-ttXO/InUULUXkMHpTdp9Fj4hLpD/2AoJdmAbAeW2yu1iy1k+pkFekQXw5VpC0/5p51IOR/jDaDRfRWRnMMsGOA==}
|
||||
peerDependencies:
|
||||
@ -3781,6 +3801,8 @@ snapshots:
|
||||
|
||||
deep-is@0.1.4: {}
|
||||
|
||||
defu@6.1.4: {}
|
||||
|
||||
delaunator@5.0.1:
|
||||
dependencies:
|
||||
robust-predicates: 3.0.2
|
||||
@ -4428,6 +4450,12 @@ snapshots:
|
||||
pify@4.0.1:
|
||||
optional: true
|
||||
|
||||
pinia-plugin-persistedstate@4.7.1(pinia@3.0.3(vue@3.5.21)):
|
||||
dependencies:
|
||||
defu: 6.1.4
|
||||
optionalDependencies:
|
||||
pinia: 3.0.3(vue@3.5.21)
|
||||
|
||||
pinia@3.0.3(vue@3.5.21):
|
||||
dependencies:
|
||||
'@vue/devtools-api': 7.7.7
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
|
||||
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
@ -10,6 +11,7 @@ import '@/assets/css/main.css'
|
||||
|
||||
const app = createApp(App)
|
||||
const pinia = createPinia()
|
||||
pinia.use(piniaPluginPersistedstate)
|
||||
|
||||
app.use(pinia)
|
||||
app.use(router)
|
||||
|
||||
@ -87,8 +87,8 @@ export const useAgentStore = defineStore('agent', () => {
|
||||
await fetchAgents()
|
||||
await fetchDefaultAgent()
|
||||
|
||||
if (!selectedAgentId.value || !agents.value.find(a => a.id === selectedAgentId.value)) {
|
||||
if (defaultAgentId.value && agents.value.find(a => a.id === defaultAgentId.value)) {
|
||||
if (!selectedAgent.value) {
|
||||
if (defaultAgent.value) {
|
||||
await selectAgent(defaultAgentId.value)
|
||||
} else if (agents.value.length > 0) {
|
||||
const firstAgentId = agents.value[0].id
|
||||
@ -356,6 +356,6 @@ export const useAgentStore = defineStore('agent', () => {
|
||||
persist: {
|
||||
key: 'agent-store',
|
||||
storage: localStorage,
|
||||
paths: ['selectedAgentId', 'defaultAgentId']
|
||||
pick: ['selectedAgentId']
|
||||
}
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user