From 2f022990d94aa66ef7d3974b5f617a9fdc1df30b Mon Sep 17 00:00:00 2001 From: wangxiang <1827945911@qq.com> Date: Sat, 16 Apr 2022 11:19:46 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=9F=20=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=8C=81=E4=B9=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kicc-ui/src/router/guard/index.ts | 2 +- kicc-ui/src/store/modules/permission.ts | 16 +++++++--------- kicc-ui/src/store/modules/user.ts | 1 - 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/kicc-ui/src/router/guard/index.ts b/kicc-ui/src/router/guard/index.ts index 561e272b..bbb01ebe 100644 --- a/kicc-ui/src/router/guard/index.ts +++ b/kicc-ui/src/router/guard/index.ts @@ -112,7 +112,7 @@ export function createMessageGuard(router: Router) { }); } -/** 处理发生请求时显示请求进度条 */ +/** 处理发送请求时显示请求进度条 */ export function createProgressGuard(router: Router) { const { getOpenNProgress } = useTransitionSetting(); router.beforeEach(async (to) => { diff --git a/kicc-ui/src/store/modules/permission.ts b/kicc-ui/src/store/modules/permission.ts index de925128..97af4f40 100644 --- a/kicc-ui/src/store/modules/permission.ts +++ b/kicc-ui/src/store/modules/permission.ts @@ -109,21 +109,19 @@ export const usePermissionStore = defineStore({ }); /** 构建菜单与路由 */ - return (await getMenuList().then(data=> { - let routeList = 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; + } + } }); // 需要在设置之外使用 diff --git a/kicc-ui/src/store/modules/user.ts b/kicc-ui/src/store/modules/user.ts index b14661a0..3c0e819d 100644 --- a/kicc-ui/src/store/modules/user.ts +++ b/kicc-ui/src/store/modules/user.ts @@ -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;