| | |
| | | export let isRelogin = { show: false }; |
| | | |
| | | axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' |
| | | // 对应国际化资源文件后缀 |
| | | axios.defaults.headers['Content-Language'] = 'zh_CN' |
| | | // 创建axios实例 |
| | | const service = axios.create({ |
| | | // axios中请求配置有baseURL选项,表示请求URL公共部分 |
| | |
| | | ).then(() => { |
| | | isRelogin.show = false; |
| | | store.dispatch('LogOut').then(() => { |
| | | location.href = '/index'; |
| | | location.href = process.env.VUE_APP_CONTEXT_PATH + "index"; |
| | | }) |
| | | }).catch(() => { |
| | | isRelogin.show = false; |
| | |
| | | type: 'error' |
| | | }) |
| | | return Promise.reject(new Error(msg)) |
| | | } else if (code === 601) { |
| | | Message({ |
| | | message: msg, |
| | | type: 'warning' |
| | | }) |
| | | return Promise.reject('error') |
| | | } else if (code !== 200) { |
| | | Notification.error({ |
| | | title: msg |
| | |
| | | ) |
| | | |
| | | // 通用下载方法 |
| | | export function download(url, params, filename) { |
| | | export function download(url, params, filename, config) { |
| | | downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", }) |
| | | return service.post(url, params, { |
| | | transformRequest: [(params) => { return tansParams(params) }], |
| | | headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, |
| | | responseType: 'blob' |
| | | responseType: 'blob', |
| | | ...config |
| | | }).then(async (data) => { |
| | | const isLogin = await blobValidate(data); |
| | | if (isLogin) { |