fix: 登录页面和退出的问题
This commit is contained in:
parent
0ca808cf94
commit
fa29c41314
|
@ -3,7 +3,7 @@
|
|||
<div class="container">
|
||||
<div class="top">
|
||||
<div class="header">
|
||||
<a href="/">
|
||||
<a href="javascript:void(0);">
|
||||
<img src="~@/assets/logo.svg" class="logo" alt="logo">
|
||||
<span class="title">安全培训平台</span>
|
||||
</a>
|
||||
|
|
|
@ -39,7 +39,7 @@ const user = {
|
|||
|
||||
actions: {
|
||||
// 登录
|
||||
Login({ commit }, userInfo) {
|
||||
Login ({ commit }, userInfo) {
|
||||
return new Promise((resolve, reject) => {
|
||||
login(userInfo).then(response => {
|
||||
storage.set(ACCESS_TOKEN, response.token, 24 * 60 * 60 * 1000)
|
||||
|
@ -52,7 +52,7 @@ const user = {
|
|||
},
|
||||
|
||||
// 获取用户信息
|
||||
GetInfo({ commit, state }) {
|
||||
GetInfo ({ commit, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
getLoginUser().then(response => {
|
||||
if (response.code === 200) {
|
||||
|
@ -76,18 +76,25 @@ const user = {
|
|||
},
|
||||
|
||||
// 登出
|
||||
Logout({ commit, state }) {
|
||||
Logout ({ commit, state }) {
|
||||
return new Promise((resolve) => {
|
||||
logout().then(() => {
|
||||
resolve()
|
||||
}).catch(() => {
|
||||
resolve()
|
||||
}).finally(() => {
|
||||
const clear = function () {
|
||||
commit('SET_TOKEN', '')
|
||||
commit('SET_ROLES', [])
|
||||
commit('SET_BUTTONS', [])
|
||||
commit('SET_ROUTERS', [])
|
||||
storage.remove(ACCESS_TOKEN)
|
||||
}
|
||||
logout().then(() => {
|
||||
clear()
|
||||
setTimeout(() => {
|
||||
resolve()
|
||||
}, 300)
|
||||
resolve()
|
||||
}).catch(() => {
|
||||
resolve()
|
||||
}).finally(() => {
|
||||
clear()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue