Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
4b46a84c
提交
4b46a84c
authored
7月 15, 2021
作者:
无木
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: infinite redirect in `BACK` mode
修复后端权限模式下的路由无限重定向的问题
上级
87583c8b
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
56 行增加
和
15 行删除
+56
-15
menu.ts
mock/sys/menu.ts
+45
-9
permissionGuard.ts
src/router/guard/permissionGuard.ts
+11
-6
没有找到文件。
mock/sys/menu.ts
浏览文件 @
4b46a84c
...
@@ -5,13 +5,40 @@ import { createFakeUserList } from './user';
...
@@ -5,13 +5,40 @@ import { createFakeUserList } from './user';
// single
// single
const
dashboardRoute
=
{
const
dashboardRoute
=
{
path
:
'/dashboard'
,
path
:
'/dashboard'
,
name
:
'Welcome'
,
name
:
'Dashboard'
,
component
:
'/dashboard/analysis/index'
,
component
:
'LAYOUT'
,
redirect
:
'/dashboard/analysis'
,
meta
:
{
meta
:
{
title
:
'routes.dashboard.
analysis
'
,
title
:
'routes.dashboard.
dashboard
'
,
affix
:
true
,
hideChildrenInMenu
:
true
,
icon
:
'bx:bx-home'
,
icon
:
'bx:bx-home'
,
},
},
children
:
[
{
path
:
'analysis'
,
name
:
'Analysis'
,
component
:
'/dashboard/analysis/index'
,
meta
:
{
hideMenu
:
true
,
hideBreadcrumb
:
true
,
title
:
'routes.dashboard.analysis'
,
currentActiveMenu
:
'/dashboard'
,
icon
:
'bx:bx-home'
,
},
},
{
path
:
'workbench'
,
name
:
'Workbench'
,
component
:
'/dashboard/workbench/index'
,
meta
:
{
hideMenu
:
true
,
hideBreadcrumb
:
true
,
title
:
'routes.dashboard.workbench'
,
currentActiveMenu
:
'/dashboard'
,
icon
:
'bx:bx-home'
,
},
},
],
};
};
const
backRoute
=
{
const
backRoute
=
{
...
@@ -223,12 +250,21 @@ export default [
...
@@ -223,12 +250,21 @@ export default [
return
resultError
(
'Invalid user token!'
);
return
resultError
(
'Invalid user token!'
);
}
}
const
id
=
checkUser
.
userId
;
const
id
=
checkUser
.
userId
;
if
(
!
id
||
id
===
'1'
)
{
let
menu
:
Object
[];
return
resultSuccess
([
dashboardRoute
,
authRoute
,
levelRoute
,
sysRoute
,
linkRoute
]);
switch
(
id
)
{
}
case
'1'
:
if
(
id
===
'2'
)
{
dashboardRoute
.
redirect
=
dashboardRoute
.
path
+
'/'
+
dashboardRoute
.
children
[
0
].
path
;
return
resultSuccess
([
dashboardRoute
,
authRoute
,
levelRoute
,
linkRoute
]);
menu
=
[
dashboardRoute
,
authRoute
,
levelRoute
,
sysRoute
,
linkRoute
];
break
;
case
'2'
:
dashboardRoute
.
redirect
=
dashboardRoute
.
path
+
'/'
+
dashboardRoute
.
children
[
1
].
path
;
menu
=
[
dashboardRoute
,
authRoute
,
levelRoute
,
linkRoute
];
break
;
default
:
menu
=
[];
}
}
return
resultSuccess
(
menu
);
},
},
},
},
]
as
MockMethod
[];
]
as
MockMethod
[];
src/router/guard/permissionGuard.ts
浏览文件 @
4b46a84c
...
@@ -19,12 +19,6 @@ export function createPermissionGuard(router: Router) {
...
@@ -19,12 +19,6 @@ export function createPermissionGuard(router: Router) {
const
userStore
=
useUserStoreWithOut
();
const
userStore
=
useUserStoreWithOut
();
const
permissionStore
=
usePermissionStoreWithOut
();
const
permissionStore
=
usePermissionStoreWithOut
();
router
.
beforeEach
(
async
(
to
,
from
,
next
)
=>
{
router
.
beforeEach
(
async
(
to
,
from
,
next
)
=>
{
// Jump to the 404 page after processing the login
if
(
from
.
path
===
LOGIN_PATH
&&
to
.
name
===
PAGE_NOT_FOUND_ROUTE
.
name
)
{
next
(
userStore
.
getUserInfo
.
homePath
||
PageEnum
.
BASE_HOME
);
return
;
}
if
(
if
(
from
.
path
===
ROOT_PATH
&&
from
.
path
===
ROOT_PATH
&&
to
.
path
===
PageEnum
.
BASE_HOME
&&
to
.
path
===
PageEnum
.
BASE_HOME
&&
...
@@ -66,6 +60,17 @@ export function createPermissionGuard(router: Router) {
...
@@ -66,6 +60,17 @@ export function createPermissionGuard(router: Router) {
return
;
return
;
}
}
// Jump to the 404 page after processing the login
if
(
from
.
path
===
LOGIN_PATH
&&
to
.
name
===
PAGE_NOT_FOUND_ROUTE
.
name
&&
to
.
fullPath
!==
(
userStore
.
getUserInfo
.
homePath
||
PageEnum
.
BASE_HOME
)
)
{
next
(
userStore
.
getUserInfo
.
homePath
||
PageEnum
.
BASE_HOME
);
console
.
log
({
from
,
to
});
return
;
}
if
(
permissionStore
.
getIsDynamicAddedRoute
)
{
if
(
permissionStore
.
getIsDynamicAddedRoute
)
{
next
();
next
();
return
;
return
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论