Browse Source

🎟 用户信息持久化

master
wangxiang 3 years ago
parent
commit
2f022990d9
  1. 2
      kicc-ui/src/router/guard/index.ts
  2. 16
      kicc-ui/src/store/modules/permission.ts
  3. 1
      kicc-ui/src/store/modules/user.ts

2
kicc-ui/src/router/guard/index.ts

@ -112,7 +112,7 @@ export function createMessageGuard(router: Router) { @@ -112,7 +112,7 @@ export function createMessageGuard(router: Router) {
});
}
/** 处理发请求时显示请求进度条 */
/** 处理发请求时显示请求进度条 */
export function createProgressGuard(router: Router) {
const { getOpenNProgress } = useTransitionSetting();
router.beforeEach(async (to) => {

16
kicc-ui/src/store/modules/permission.ts

@ -109,21 +109,19 @@ export const usePermissionStore = defineStore({ @@ -109,21 +109,19 @@ export const usePermissionStore = defineStore({
});
/** 构建菜单与路由 */
return (await getMenuList().then(data=> {
let routeList = <AppRouteRecordRaw[]>data;
// 将菜单对象变成路由对象
let routeList: AppRouteRecordRaw[] = [];
try {
let routeList: AppRouteRecordRaw[] = (await getMenuList()) as AppRouteRecordRaw[];
transformObjToRoute(routeList);
const menuList = transformRouteToMenu(routeList);
this.setMenuList(menuList);
// 过滤忽略路由配置项,只构建菜单不构建路由
routeList = filter(routeList, routeRemoveIgnoreFilter);
patchHomeAffix(routeList);
return routeList;
}).catch(error => {
console.error(error);
})) as AppRouteRecordRaw[];
},
},
} catch (error) { console.error(error); }
return routeList;
}
}
});
// 需要在设置之外使用

1
kicc-ui/src/store/modules/user.ts

@ -103,7 +103,6 @@ export const useUserStore = defineStore({ @@ -103,7 +103,6 @@ export const useUserStore = defineStore({
const { access_token, refresh_token } = data;
this.setAccessToken(access_token);
this.setRefreshToken(refresh_token);
// 获取用户信息
const userInfo = await this.getUserInfoAction();
const sessionTimeout = this.sessionTimeout;

Loading…
Cancel
Save