Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tea_resources_pc
Project
Project
Details
Activity
Releases
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
张伯涛
tea_resources_pc
Commits
61508a4d
Commit
61508a4d
authored
Jun 28, 2024
by
刘帅阳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
token问题
parent
f501b97d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
9 deletions
+34
-9
login.js
src/api/login.js
+7
-0
request.js
src/utils/request.js
+11
-2
index.vue
src/views/homePage/components/NavList/index.vue
+16
-7
No files found.
src/api/login.js
View file @
61508a4d
...
...
@@ -21,6 +21,13 @@ export function login(username, password, code, uuid, type) {
headers
:
{}
})
}
export
function
handleLogout
()
{
return
request
({
url
:
'/auth/logout'
,
method
:
'get'
})
}
// 手机登录方法
export
function
phoneLogin
(
phone
,
smsCode
)
{
const
data
=
{
...
...
src/utils/request.js
View file @
61508a4d
...
...
@@ -6,7 +6,7 @@ import { getToken, setToken } from '@/utils/auth'
import
SM4
from
'./gmUtil'
import
errorCode
from
'@/utils/errorCode'
import
{
refreshToken
}
from
'@/api/login.js'
import
router
from
'../router'
axios
.
defaults
.
headers
[
'Content-Type'
]
=
'application/x-www-form-urlencoded'
// 创建axios实例
const
service
=
axios
.
create
({
...
...
@@ -95,9 +95,18 @@ service.interceptors.response.use(
}
if
(
code
===
401
)
{
Message
({
message
:
'
用户不存在或密码错误
'
,
message
:
'
当前登录无权限,请重新登录
'
,
type
:
'error'
})
console
.
log
(
'401401'
)
store
.
dispatch
(
'FedLogOut'
).
then
(()
=>
{
router
.
push
({
path
:
'/login/index'
})
setTimeout
(()
=>
{
location
.
reload
()
},
500
)
})
}
else
if
(
code
===
500
||
code
===
400
)
{
const
errMsg
=
res
.
data
.
data
||
res
.
data
.
message
||
res
.
data
.
msg
Message
({
...
...
src/views/homePage/components/NavList/index.vue
View file @
61508a4d
...
...
@@ -144,6 +144,7 @@
<
script
>
import
{
mapGetters
}
from
'vuex'
import
{
getToken
}
from
'@/utils/auth'
import
{
handleLogout
}
from
"@/api/login"
;
export
default
{
name
:
'NavList'
,
...
...
@@ -221,13 +222,21 @@ export default {
cancelButtonText
:
'取消'
,
type
:
'warning'
}).
then
(()
=>
{
this
.
$store
.
dispatch
(
'FedLogOut'
).
then
(()
=>
{
this
.
$router
.
push
({
path
:
'/homePage/index'
})
setTimeout
(()
=>
{
location
.
reload
()
},
500
)
handleLogout
().
then
(
res
=>
{
if
(
res
.
code
===
200
)
{
this
.
$message
({
message
:
'退出成功'
,
type
:
'success'
})
this
.
$store
.
dispatch
(
'FedLogOut'
).
then
(()
=>
{
this
.
$router
.
push
({
path
:
'/homePage/index'
})
setTimeout
(()
=>
{
location
.
reload
()
},
500
)
})
}
})
})
},
...
...
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