请求返回 401,402 清除用户登录信息

This commit is contained in:
ronger 2020-08-11 11:13:30 +08:00
parent c83103dac8
commit c5afbd0a60

View File

@ -1,4 +1,4 @@
// const Cookie = require('js-cookie') const Cookie = require('js-cookie')
export default function ({app, $axios, store, redirect}) { export default function ({app, $axios, store, redirect}) {
$axios.onRequest(config => { $axios.onRequest(config => {
let token = store.state.oauth?.accessToken; let token = store.state.oauth?.accessToken;
@ -23,10 +23,10 @@ export default function ({app, $axios, store, redirect}) {
if (response.data.code === '0') { if (response.data.code === '0') {
app.$message(message); app.$message(message);
} else if (response.data.code === '401') { } else if (response.data.code === '401') {
// Cookie.remove('auth') Cookie.remove('auth')
store.commit('setAuth', null); store.commit('setAuth', null);
} else if (response.data.code === '402') { } else if (response.data.code === '402') {
// Cookie.remove('auth') Cookie.remove('auth')
store.commit('setAuth', null); store.commit('setAuth', null);
} else if (response.data.code === '404') { } else if (response.data.code === '404') {
app.$message('操作失败,请稍后再试......') app.$message('操作失败,请稍后再试......')