Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
JWTVueDemo
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jay
JWTVueDemo
Commits
b722a8c0
Commit
b722a8c0
authored
Jun 18, 2020
by
Jay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登入頁面導向
parent
63ccc575
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
12 deletions
+21
-12
JWTVueDemo/ClientApp/src/main.js
+9
-2
JWTVueDemo/ClientApp/src/router/index.js
+5
-9
JWTVueDemo/ClientApp/src/views/Login.vue
+7
-1
No files found.
JWTVueDemo/ClientApp/src/main.js
View file @
b722a8c0
...
...
@@ -27,7 +27,7 @@ router.beforeEach((to, from, next) => {
next
();
}
else
{
alert
(
'沒有權限進入該頁面'
);
next
(
from
.
path
);
next
(
'/home'
);
}
}
else
{
next
(
from
.
path
);
...
...
@@ -38,7 +38,14 @@ router.beforeEach((to, from, next) => {
if
(
to
.
path
===
'/login'
)
{
next
();
}
else
{
next
(
'/login'
);
localStorage
.
setItem
(
'lastUrl'
,
to
.
fullPath
);
// this.$router.push({ name: 'login', query: { redirect: '/path' } });
next
({
path
:
'/login'
,
query
:
{
nextUrl
:
to
.
fullPath
}
});
}
}
});
...
...
JWTVueDemo/ClientApp/src/router/index.js
View file @
b722a8c0
import
Vue
from
'vue'
;
import
VueRouter
from
'vue-router'
;
import
Home
from
'../views/Home.vue'
;
import
PageA
from
'../views/PageA.vue'
;
import
PageB
from
'../views/PageB.vue'
;
import
PageC
from
'../views/PageC.vue'
;
import
Login
from
'../views/Login.vue'
;
Vue
.
use
(
VueRouter
);
const
routes
=
[
{
path
:
'/login'
,
name
:
'login'
,
component
:
()
=>
import
(
/* webpackChunkName: "login" */
'../views/Login.vue'
),
isMenu
:
false
// props: { title: '登入' },
component
:
Login
},
{
path
:
'/home'
,
...
...
@@ -27,7 +23,7 @@ const routes = [
{
path
:
'/PageA'
,
name
:
'PageA'
,
component
:
PageA
,
component
:
()
=>
import
(
/* webpackChunkName: "PageA" */
'../views/PageA.vue'
)
,
isMenu
:
true
,
icon
:
'mdi-home'
,
admin
:
true
,
...
...
@@ -37,7 +33,7 @@ const routes = [
{
path
:
'/PageB'
,
name
:
'PageB'
,
component
:
PageB
,
component
:
()
=>
import
(
/* webpackChunkName: "PageB" */
'../views/PageB.vue'
)
,
isMenu
:
true
,
icon
:
'mdi-home'
,
admin
:
true
,
...
...
@@ -47,7 +43,7 @@ const routes = [
{
path
:
'/PageC'
,
name
:
'PageC'
,
component
:
PageC
,
component
:
()
=>
import
(
/* webpackChunkName: "PageC" */
'../views/PageC.vue'
)
,
isMenu
:
true
,
icon
:
'mdi-home'
,
admin
:
true
,
...
...
JWTVueDemo/ClientApp/src/views/Login.vue
View file @
b722a8c0
...
...
@@ -52,7 +52,13 @@ export default {
Password
:
this
.
password
});
if
(
loginState
.
Success
)
{
this
.
$router
.
push
(
'/home'
);
const
url
=
localStorage
.
getItem
(
'lastUrl'
);
if
(
url
)
{
localStorage
.
removeItem
(
'lastUrl'
);
this
.
$router
.
push
(
url
);
}
else
{
this
.
$router
.
push
(
'/home'
);
}
}
else
{
this
.
snackbarVisible
=
true
;
this
.
errMsg
=
loginState
.
Msg
;
...
...
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