Эх сурвалжийг харах

2023-11-29 feat: 持久化缓存

YunaiV 1 жил өмнө
parent
commit
3be088e370

+ 1 - 1
package.json

@@ -55,7 +55,7 @@
     "mitt": "^3.0.1",
     "nprogress": "^0.2.0",
     "pinia": "^2.1.7",
-    "pinia-plugin-persist": "^1.0.0",
+    "pinia-plugin-persistedstate": "^3.2.0",
     "qrcode": "^1.5.3",
     "qs": "^6.11.2",
     "steady-xml": "^0.1.0",

+ 2 - 2
src/store/index.ts

@@ -1,9 +1,9 @@
 import type { App } from 'vue'
 import { createPinia } from 'pinia'
-import piniaPersist from 'pinia-plugin-persist'
+import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
 
 const store = createPinia()
-store.use(piniaPersist)
+store.use(piniaPluginPersistedstate)
 
 export const setupStore = (app: App<Element>) => {
   app.use(store)

+ 2 - 1
src/store/modules/app.ts

@@ -268,7 +268,8 @@ export const useAppStore = defineStore('app', {
     setFooter(footer: boolean) {
       this.footer = footer
     }
-  }
+  },
+  persist: false
 })
 
 export const useAppStoreWithOut = () => {

+ 1 - 5
src/store/modules/lock.ts

@@ -10,7 +10,6 @@ interface LockState {
   lockInfo: lockInfo
 }
 
-// TODO 芋艿:【锁屏】这里有报错,后续解决下
 export const useLockStore = defineStore('lock', {
   state: (): LockState => {
     return {
@@ -41,10 +40,7 @@ export const useLockStore = defineStore('lock', {
       }
     }
   },
-  persist: {
-    enabled: true,
-    strategies: [{ key: 'lock', storage: localStorage }]
-  }
+  persist: true
 })
 
 export const useLockStoreWithOut = () => {

+ 2 - 1
src/store/modules/permission.ts

@@ -59,7 +59,8 @@ export const usePermissionStore = defineStore('permission', {
     setMenuTabRouters(routers: AppRouteRecordRaw[]): void {
       this.menuTabRouters = routers
     }
-  }
+  },
+  persist: false
 })
 
 export const usePermissionStoreWithOut = () => {

+ 2 - 1
src/store/modules/tagsView.ts

@@ -132,7 +132,8 @@ export const useTagsViewStore = defineStore('tagsView', {
         }
       }
     }
-  }
+  },
+  persist: false
 })
 
 export const useTagsViewStoreWithOut = () => {