Commit 4ce66a95 by 姜雷

处理token过期登出

parent a42f6dea
...@@ -56,7 +56,7 @@ service.interceptors.response.use(response => { ...@@ -56,7 +56,7 @@ service.interceptors.response.use(response => {
}); });
// -2:其他客户端登录了;Token 过期了; // -2:其他客户端登录了;Token 过期了;
if (res.code === '-2') { if (res.code === -2) {
if (logout) return; if (logout) return;
logout = true; logout = true;
MessageBox.confirm( MessageBox.confirm(
......
...@@ -53,7 +53,13 @@ const actions = { ...@@ -53,7 +53,13 @@ const actions = {
// 登出 // 登出
LogOut({ commit, state }) { LogOut({ commit, state }) {
return logout(state.token).then(() => { return logout(state.token)
.then(() => {
commit(SET_TOKEN, '');
removeToken();
})
.catch(err => {
console.log(err);
commit(SET_TOKEN, ''); commit(SET_TOKEN, '');
removeToken(); removeToken();
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment