Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
W
web-monitor
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Administrator
web-monitor
Commits
ccd07c3d
Commit
ccd07c3d
authored
Sep 07, 2018
by
Pan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature: add a redirect url when not logged in
https://github.com/PanJiaChen/vue-element-admin/issues/438
parent
337b12be
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
permission.js
src/permission.js
+1
-1
index.vue
src/views/login/index.vue
+11
-2
No files found.
src/permission.js
View file @
ccd07c3d
...
...
@@ -30,7 +30,7 @@ router.beforeEach((to, from, next) => {
if
(
whiteList
.
indexOf
(
to
.
path
)
!==
-
1
)
{
next
()
}
else
{
next
(
'/login'
)
next
(
`/login?redirect=
${
to
.
path
}
`
)
// 否则全部重定向到登录页
NProgress
.
done
()
}
}
...
...
src/views/login/index.vue
View file @
ccd07c3d
...
...
@@ -66,7 +66,16 @@ export default {
password
:
[{
required
:
true
,
trigger
:
'blur'
,
validator
:
validatePass
}]
},
loading
:
false
,
pwdType
:
'password'
pwdType
:
'password'
,
redirect
:
undefined
}
},
watch
:
{
$route
:
{
handler
:
function
(
route
)
{
this
.
redirect
=
route
.
query
&&
route
.
query
.
redirect
},
immediate
:
true
}
},
methods
:
{
...
...
@@ -83,7 +92,7 @@ export default {
this
.
loading
=
true
this
.
$store
.
dispatch
(
'Login'
,
this
.
loginForm
).
then
(()
=>
{
this
.
loading
=
false
this
.
$router
.
push
({
path
:
'/'
})
this
.
$router
.
push
({
path
:
this
.
redirect
||
'/'
})
}).
catch
(()
=>
{
this
.
loading
=
false
})
...
...
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