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