We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0e25941 commit 33fa473Copy full SHA for 33fa473
1 file changed
src/store/modules/user.ts
@@ -1,6 +1,6 @@
1
import { defineStore } from 'pinia';
2
import { TOKEN_NAME } from '@/config/global';
3
-import { store } from '@/store';
+import { store, usePermissionStore } from '@/store';
4
5
const InitUserInfo = {
6
roles: [],
@@ -79,6 +79,14 @@ export const useUserStore = defineStore('user', {
79
this.token = '';
80
},
81
82
+ persist: {
83
+ afterRestore: (ctx) => {
84
+ if (ctx.store.roles && ctx.store.roles.length > 0) {
85
+ const permissionStore = usePermissionStore();
86
+ permissionStore.initRoutes(ctx.store.roles);
87
+ }
88
+ },
89
90
});
91
92
export function getUserStore() {
0 commit comments