Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sensorConsult
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
zhanglw
sensorConsult
Commits
5bbc94fc
Commit
5bbc94fc
authored
Jun 15, 2023
by
zhanglw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
后台登录重定向
parent
473529cb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
index.js
src/router/index.js
+14
-1
routers.js
src/router/routers.js
+5
-0
No files found.
src/router/index.js
View file @
5bbc94fc
...
...
@@ -9,7 +9,8 @@ import { filterAsyncRouter } from '@/store/modules/permission'
NProgress
.
configure
({
showSpinner
:
false
})
// NProgress Configuration
const
whiteList
=
[
'
/login
'
,
'
/home
'
]
// no redirect whitelist
const
whiteList
=
[
'
/login
'
,
'
/backlogin
'
,
'
/home
'
]
// 免登录路由白名单
const
backUrlList
=
[
'
/dashboard
'
,
'
/system
'
,
'
/monitor
'
,
'
/sys-tools
'
,
'
/backstage
'
]
// 后台路由
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
if
(
to
.
meta
.
title
)
{
...
...
@@ -41,9 +42,21 @@ router.beforeEach((to, from, next) => {
}
}
}
else
{
const
findUrl
=
(
urlList
,
path
)
=>
{
let
flag
=
false
urlList
.
forEach
(
url
=>
{
if
(
path
.
indexOf
(
url
)
!==
-
1
)
{
flag
=
true
}
})
return
flag
}
/* has no token*/
if
(
whiteList
.
indexOf
(
to
.
path
)
!==
-
1
)
{
// 在免登录白名单,直接进入
next
()
}
else
if
(
findUrl
(
backUrlList
,
to
.
path
))
{
// 后台路由重定向到后台登录
next
(
`/backlogin?redirect=
${
to
.
fullPath
}
`
)
NProgress
.
done
()
}
else
{
next
(
`/login?redirect=
${
to
.
fullPath
}
`
)
// 否则全部重定向到登录页
NProgress
.
done
()
...
...
src/router/routers.js
View file @
5bbc94fc
...
...
@@ -10,6 +10,11 @@ export const constantRouterMap = [
component
:
(
resolve
)
=>
require
([
'
@/views/login
'
],
resolve
),
hidden
:
true
},
{
path
:
'
/backlogin
'
,
meta
:
{
title
:
'
后台登录
'
,
noCache
:
true
},
component
:
(
resolve
)
=>
require
([
'
@/views/login
'
],
resolve
),
hidden
:
true
},
{
path
:
'
/404
'
,
component
:
(
resolve
)
=>
require
([
'
@/views/features/404
'
],
resolve
),
...
...
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