diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 575af0f..2fad24e 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -1,6 +1,6 @@ import { defineStore } from 'pinia'; import { TOKEN_NAME } from '@/config/global'; -import { store } from '@/store'; +import { store, usePermissionStore } from '@/store'; const InitUserInfo = { roles: [], @@ -79,6 +79,14 @@ export const useUserStore = defineStore('user', { this.token = ''; }, }, + persist: { + afterRestore: (ctx) => { + if (ctx.store.roles && ctx.store.roles.length > 0) { + const permissionStore = usePermissionStore(); + permissionStore.initRoutes(ctx.store.roles); + } + }, + }, }); export function getUserStore() {