Skip to content

Commit 5fcd3fe

Browse files
committed
fix: 在路由守卫中捕获异常时,添加登出逻辑
1 parent ee47369 commit 5fcd3fe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

‎src/router/guards.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function setupRoutes(router: Router) {
4747
}
4848
else {
4949
try {
50-
// 获取用户权限
50+
// 获取用户权限
5151
settingsStore.settings.app.enablePermission && await userStore.getPermissions()
5252
// 生成动态路由
5353
switch (settingsStore.settings.app.routeBaseOn) {
@@ -85,7 +85,9 @@ function setupRoutes(router: Router) {
8585
}
8686
routeStore.setCurrentRemoveRoutes(removeRoutes)
8787
}
88-
catch {}
88+
catch {
89+
userStore.logout()
90+
}
8991
// 动态路由生成并注册后,重新进入当前路由
9092
next({
9193
path: to.path,

0 commit comments

Comments
 (0)