chore(auth): 解决ts 类型检查报错

This commit is contained in:
2026-01-22 14:38:19 +08:00
parent d712f9a5bf
commit be5078ae0d
5 changed files with 15 additions and 6 deletions

View File

@@ -14,6 +14,10 @@ export namespace AuthApi {
* 最后登录时间
*/
lastTime: string;
/**
* 角色列表
*/
role: string;
}
/** 登录接口返回值 */

View File

@@ -93,7 +93,7 @@ function setupAccessGuard(router: Router) {
// 生成路由表
// 当前登录用户拥有的角色标识列表
const userInfo = userStore.userInfo || (await authStore.fetchUserInfo());
const userRoles = userInfo.roles ?? [];
const userRoles = userInfo?.roles ?? [];
// 生成菜单和路由
const { accessibleMenus, accessibleRoutes } = await generateAccess({
@@ -109,7 +109,7 @@ function setupAccessGuard(router: Router) {
accessStore.setIsAccessChecked(true);
const redirectPath = (from.query.redirect ??
(to.path === preferences.app.defaultHomePath
? userInfo.homePath || preferences.app.defaultHomePath
? userInfo?.homePath || preferences.app.defaultHomePath
: to.fullPath)) as string;
return {

View File

@@ -43,6 +43,7 @@ export const useAuthStore = defineStore('auth', () => {
// ]);
userInfo = userEntity;
userInfo.roles = userEntity.role ? [userEntity.role] : [];
userStore.setUserInfo(userInfo);
// accessStore.setAccessCodes(accessCodes);