diff --git a/package.json b/package.json index 37efeb7..a374c42 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "mitt": "^3.0.1", "nprogress": "^0.2.0", "pinia": "^2.1.7", + "pinia-plugin-persistedstate": "^3.2.1", "query-string": "^8.1.0", "sortablejs": "^1.15.1", "v-viewer": "^3.0.10", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dad9f0d..0046a77 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -53,6 +53,9 @@ dependencies: pinia: specifier: ^2.1.7 version: 2.1.7(typescript@5.4.3)(vue@3.3.7) + pinia-plugin-persistedstate: + specifier: ^3.2.1 + version: 3.2.1(pinia@2.1.7) query-string: specifier: ^8.1.0 version: 8.2.0 @@ -6797,6 +6800,14 @@ packages: resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==} engines: {node: '>=6'} + /pinia-plugin-persistedstate@3.2.1(pinia@2.1.7): + resolution: {integrity: sha512-MK++8LRUsGF7r45PjBFES82ISnPzyO6IZx3CH5vyPseFLZCk1g2kgx6l/nW8pEBKxxd4do0P6bJw+mUSZIEZUQ==} + peerDependencies: + pinia: ^2.0.0 + dependencies: + pinia: 2.1.7(typescript@5.4.3)(vue@3.3.7) + dev: false + /pinia@2.1.7(typescript@5.4.3)(vue@3.3.7): resolution: {integrity: sha512-+C2AHFtcFqjPih0zpYuvof37SFxMQ7OEG2zV9jRI12i9BOy3YQVAHwdKtyyc8pDcDyIc33WCIsZaCFWU7WWxGQ==} peerDependencies: diff --git a/src/store/index.ts b/src/store/index.ts index f4838cd..5217fa8 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,10 +1,11 @@ import { createPinia } from 'pinia'; +import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'; import useAppStore from './modules/app'; import useUserStore from './modules/user'; import useDictStore from './modules/dict'; import useTabBarStore from './modules/tab-bar'; const pinia = createPinia(); - +pinia.use(piniaPluginPersistedstate); export { useAppStore, useUserStore, useDictStore, useTabBarStore }; export default pinia; diff --git a/src/store/modules/app/index.ts b/src/store/modules/app/index.ts index 401dee5..9b44dd9 100644 --- a/src/store/modules/app/index.ts +++ b/src/store/modules/app/index.ts @@ -27,7 +27,6 @@ const recursionMenu = ( }; const useAppStore = defineStore('app', { state: (): AppState => ({ ...defaultSettings, config: {} }), - getters: { appCurrentSetting(state: AppState): AppState { return { ...state }; @@ -155,6 +154,7 @@ const useAppStore = defineStore('app', { ); }, }, + persist: true, }); export default useAppStore;