Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
front-backend
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
framework
front-backend
Commits
ecf4ef98
Commit
ecf4ef98
authored
Jun 04, 2020
by
ZhengJie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[代码完善](v2.5): v2.5 修改Token过期的提示
由原来的弹窗提示改为登录界面消息提示
parent
acfb22bb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
12 deletions
+21
-12
src/utils/request.js
+5
-12
src/views/login.vue
+16
-0
No files found.
src/utils/request.js
View file @
ecf4ef98
import
axios
from
'axios'
import
router
from
'@/router/routers'
import
{
Notification
,
MessageBox
}
from
'element-ui'
import
{
Notification
}
from
'element-ui'
import
store
from
'../store'
import
{
getToken
}
from
'@/utils/auth'
import
Config
from
'@/settings'
import
Cookies
from
'js-cookie'
// 创建axios实例
const
service
=
axios
.
create
({
...
...
@@ -55,18 +56,10 @@ service.interceptors.response.use(
}
if
(
code
)
{
if
(
code
===
401
)
{
MessageBox
.
confirm
(
'登录状态已过期,您可以继续留在该页面,或者重新登录'
,
'系统提示'
,
{
confirmButtonText
:
'重新登录'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
}
).
then
(()
=>
{
store
.
dispatch
(
'LogOut'
).
then
(()
=>
{
location
.
reload
()
// 为了重新实例化vue-router对象 避免bug
})
// 用户登录界面提示
Cookies
.
set
(
'point'
,
401
)
location
.
reload
()
})
}
else
if
(
code
===
403
)
{
router
.
push
({
path
:
'/401'
})
...
...
src/views/login.vue
View file @
ecf4ef98
...
...
@@ -79,8 +79,12 @@ export default {
}
},
created
()
{
// 获取验证码
this
.
getCode
()
// 获取用户名密码等Cookie
this
.
getCookie
()
// token 过期提示
this
.
point
()
},
methods
:
{
getCode
()
{
...
...
@@ -138,6 +142,18 @@ export default {
return
false
}
})
},
point
()
{
const
point
=
Cookies
.
get
(
'point'
)
!==
undefined
if
(
point
)
{
this
.
$notify
({
title
:
'提示'
,
message
:
'当前登录状态已过期,请重新登录!'
,
type
:
'warning'
,
duration
:
8000
})
Cookies
.
remove
(
'point'
)
}
}
}
}
...
...
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