| | |
| | | import router from '@/router'; |
| | | import { serialize } from '@/utils/common' |
| | | import { getToken } from '@/utils/auth'; |
| | | import { ElMessage } from 'element-plus'; |
| | | import { showNotify } from 'vant'; |
| | | import website from '@/config/website'; |
| | | import { Base64 } from 'js-base64' |
| | | // import NProgress from 'nprogress'; |
| | |
| | | url: string |
| | | authorization: boolean |
| | | }) => { |
| | | if(config.url.includes('h5')) { |
| | | config.url = '/drone-h5' + config.url |
| | | } else if (!config.url.includes('/blade-') && !config.url.includes('https://') && !config.url.includes('http://')) { |
| | | config.url = '/drone-yw' + config.url |
| | | if (!config.url.includes('/blade-') && !config.url.includes('https://') && !config.url.includes('http://')) { |
| | | config.url = '/drone-device-core' + config.url |
| | | } |
| | | const authorization = config.authorization === false |
| | | if (!authorization) { |
| | |
| | | const isToken = meta.isToken === false |
| | | if (getToken() && !isToken) { |
| | | config.headers[website.tokenHeader] = 'bearer ' + getToken() |
| | | } else { |
| | | // 为了兼容分享页面 |
| | | config.headers[website.tokenHeader] = 'bearer ' + getAuthToken() |
| | | } |
| | | if (meta.noCookie) { |
| | | delete config.headers.cookie |
| | |
| | | return Promise.reject(new Error(message)) |
| | | } |
| | | if (message === '缺失令牌,鉴权失败') { |
| | | ElMessage.warning('登录信息已过期,请重新登录') |
| | | showNotify({ type: 'warning', message: '登录信息已过期,请重新登录' }) |
| | | } |
| | | if ( |
| | | ![ |
| | |
| | | '缺失令牌,鉴权失败', |
| | | ].includes(message) |
| | | ) { |
| | | ElMessage.warning(message) |
| | | showNotify({ type: 'warning', message: message }) |
| | | } |
| | | return Promise.reject(new Error(message)) |
| | | } |
| | |
| | | description = err.response.data.result.message |
| | | } |
| | | if (!err.response || !err.response.status) { |
| | | ElMessage.error('网络异常,请检查后端服务后重试') |
| | | showNotify({ type: 'danger', message: '网络异常,请检查后端服务后重试' }) |
| | | return |
| | | } |
| | | if (err.response?.status !== 200) { |
| | | if (err.response.data?.msg) { |
| | | ElMessage.error(err.response.data?.msg) |
| | | showNotify({ type: 'danger', message: err.response.data?.msg }) |
| | | } else if (err.response.data?.error_description) { |
| | | ElMessage.error(err.response.data?.error_description) |
| | | showNotify({ type: 'danger', message: err.response.data?.error_description }) |
| | | } else { |
| | | ElMessage.error(`错误码: ${err.response?.status}`) |
| | | showNotify({ type: 'danger', message: `错误码: ${err.response?.status}` }) |
| | | } |
| | | } |
| | | if (err.response?.status == 401) { |