Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
4b46a84c
Commit
4b46a84c
authored
Jul 15, 2021
by
无木
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: infinite redirect in `BACK` mode
修复后端权限模式下的路由无限重定向的问题
parent
87583c8b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
15 deletions
+56
-15
menu.ts
mock/sys/menu.ts
+45
-9
permissionGuard.ts
src/router/guard/permissionGuard.ts
+11
-6
No files found.
mock/sys/menu.ts
View file @
4b46a84c
...
...
@@ -5,13 +5,40 @@ import { createFakeUserList } from './user';
// single
const
dashboardRoute
=
{
path
:
'
/dashboard
'
,
name
:
'
Welcome
'
,
component
:
'
/dashboard/analysis/index
'
,
name
:
'
Dashboard
'
,
component
:
'
LAYOUT
'
,
redirect
:
'
/dashboard/analysis
'
,
meta
:
{
title
:
'
routes.dashboard.
analysis
'
,
affix
:
true
,
title
:
'
routes.dashboard.
dashboard
'
,
hideChildrenInMenu
:
true
,
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
=
{
...
...
@@ -223,12 +250,21 @@ export default [
return
resultError
(
'
Invalid user token!
'
);
}
const
id
=
checkUser
.
userId
;
if
(
!
id
||
id
===
'
1
'
)
{
return
resultSuccess
([
dashboardRoute
,
authRoute
,
levelRoute
,
sysRoute
,
linkRoute
]);
}
if
(
id
===
'
2
'
)
{
return
resultSuccess
([
dashboardRoute
,
authRoute
,
levelRoute
,
linkRoute
]);
let
menu
:
Object
[];
switch
(
id
)
{
case
'
1
'
:
dashboardRoute
.
redirect
=
dashboardRoute
.
path
+
'
/
'
+
dashboardRoute
.
children
[
0
].
path
;
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
[];
src/router/guard/permissionGuard.ts
View file @
4b46a84c
...
...
@@ -19,12 +19,6 @@ export function createPermissionGuard(router: Router) {
const
userStore
=
useUserStoreWithOut
();
const
permissionStore
=
usePermissionStoreWithOut
();
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
(
from
.
path
===
ROOT_PATH
&&
to
.
path
===
PageEnum
.
BASE_HOME
&&
...
...
@@ -66,6 +60,17 @@ export function createPermissionGuard(router: Router) {
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
)
{
next
();
return
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment