mirror of
https://github.com/Tencent/tdesign-vue-next-starter.git
synced 2024-11-10 06:58:23 +08:00
fix: 修复持久化的问题 (#316)
* fix: 修正首次进入页面时由于userStore数据还未初始化导致的白屏的问题 * Update user.ts fix: 优化逻辑
This commit is contained in:
parent
0e259413ca
commit
33fa473761
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user