mirror of
https://github.com/vbenjs/gf-vben-admin.git
synced 2025-01-24 04:10:20 +08:00
fix: add loss action for userStore
This commit is contained in:
parent
628e820684
commit
a36825a6d4
@ -94,13 +94,20 @@ export const useUserStore = defineStore({
|
||||
|
||||
// save token
|
||||
this.setToken(token);
|
||||
return this.afterLoginAction(goHome);
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
},
|
||||
async afterLoginAction(goHome?: boolean): Promise<GetUserInfoModel | null> {
|
||||
if (!this.getToken) return null;
|
||||
// get user info
|
||||
const userInfo = await this.getUserInfoAction();
|
||||
|
||||
const sessionTimeout = this.sessionTimeout;
|
||||
if (sessionTimeout) {
|
||||
this.setSessionTimeout(false);
|
||||
} else if (goHome) {
|
||||
} else {
|
||||
const permissionStore = usePermissionStore();
|
||||
if (!permissionStore.isDynamicAddedRoute) {
|
||||
const routes = await permissionStore.buildRoutesAction();
|
||||
@ -110,12 +117,9 @@ export const useUserStore = defineStore({
|
||||
router.addRoute(PAGE_NOT_FOUND_ROUTE as unknown as RouteRecordRaw);
|
||||
permissionStore.setDynamicAddedRoute(true);
|
||||
}
|
||||
await router.replace(userInfo.homePath || PageEnum.BASE_HOME);
|
||||
goHome && (await router.replace(userInfo.homePath || PageEnum.BASE_HOME));
|
||||
}
|
||||
return userInfo;
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
},
|
||||
async getUserInfoAction(): Promise<UserInfo> {
|
||||
const userInfo = await getUserInfo();
|
||||
|
Loading…
Reference in New Issue
Block a user