| | |
| | | let isRefreshing = false; // 标记当前是否正在刷新token |
| | | let refreshTokenPromise = null; // 刷新token的Promise,避免重复请求 |
| | | |
| | | axios.defaults.timeout = 10000; |
| | | axios.defaults.timeout = 30000; |
| | | //返回其他状态码 |
| | | axios.defaults.validateStatus = function (status) { |
| | | return status >= 200 && status <= 500; // 默认的 |
| | |
| | | const message = res.data.msg || res.data.error_description || '系统错误'; |
| | | //如果在白名单里则自行catch逻辑处理 |
| | | if (statusWhiteList.includes(status)) return Promise.reject(res); |
| | | |
| | | // 如果是401并且没有重试过,尝试刷新token |
| | | if (status === 401 && !config._retry) { |
| | | config._retry = true; |
| | |
| | | } |
| | | |
| | | // 如果请求为非200则默认统一处理 |
| | | if (status !== 200) { |
| | | if (status !== 200 && status != 2) { |
| | | ElMessage({ |
| | | message: message, |
| | | type: 'error', |