| | |
| | | import store from '@/store' |
| | | import { getToken } from '@/utils/auth' |
| | | import errorCode from '@/utils/errorCode' |
| | | import cache from '@/plugins/cache' |
| | | |
| | | |
| | | axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' |
| | | // 创建axios实例 |
| | |
| | | // request拦截器 |
| | | service.interceptors.request.use(config => { |
| | | // 是否需要设置 token |
| | | const isToken = (config.headers || {}).isToken === false |
| | | // const isToken = (config.headers || {}).isToken === false |
| | | const isToken = false; |
| | | const isRepeatSubmit = (config.headers || {}).repeatSubmit === false |
| | | |
| | | if (getToken() && !isToken) { |
| | |
| | | location.href = '/index'; |
| | | }) |
| | | }).catch(() => {}); |
| | | return Promise.reject('无效的会话,或者会话已过期,请重新登录。') |
| | | } else if (code === 500) { |
| | | // Message({ |
| | | // message: msg, |
| | | // type: 'error' |
| | | // }) |
| | | console.log(msg); |
| | | return Promise.reject(new Error(msg)) |
| | | } else if (code !== 200) { |
| | | // Notification.error({ |
| | | // title: msg |
| | | // }) |
| | | console.log(msg); |
| | | return Promise.reject('error') |
| | | return Promise.reject('无效的会话,或者会话已过期,请重新登录1。') |
| | | } else { |
| | | return res.data |
| | | } |