|  |  |  | 
|---|
|  |  |  | import pkg from '../../../package' | 
|---|
|  |  |  | import { trim } from '@/utils/util' | 
|---|
|  |  |  | import extendsMethods from './extends.methods' | 
|---|
|  |  |  | import { decryptedData } from './decryption.js' | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 默认配置 | 
|---|
|  |  |  | axios.defaults.headers.common['Content-Type'] = 'application/json;charset=UTF-8' | 
|---|
|  |  |  | const axiosInstance = axios.create({ | 
|---|
|  |  |  | baseURL: process.env.VUE_APP_API_PREFIX, | 
|---|
|  |  |  | // 请求超时时间 | 
|---|
|  |  |  | timeout: 60000 | 
|---|
|  |  |  | timeout: 600000 | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 新建请求拦截器 | 
|---|
|  |  |  | 
|---|
|  |  |  | config.params = trim(config.params) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (config.ivKey) { | 
|---|
|  |  |  | config.headers.secretKey = config.ivKey | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // config.headers['Content-Type'] = config.contentType || 'application/json;charset=UTF-8' | 
|---|
|  |  |  | // 导出处理 | 
|---|
|  |  |  | if (config.download === true) { | 
|---|
|  |  |  | config.responseType = 'blob' | 
|---|
|  |  |  | 
|---|
|  |  |  | // 未登录 | 
|---|
|  |  |  | if (response.data.code === 401) { | 
|---|
|  |  |  | if (response.config.autoLogin !== false) { | 
|---|
|  |  |  | window.location.href = process.env.VUE_APP_ROUTER_MODE === 'history' ? '/#/login' : '/login' | 
|---|
|  |  |  | window.location.href = process.env.VUE_APP_ROUTER_MODE === 'hash' ? (process.env.VUE_APP_CONTEXT_PATH + '/#/login') : (process.env.VUE_APP_CONTEXT_PATH + '/login') | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return Promise.reject(response.data) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if (!response.data.success) { | 
|---|
|  |  |  | return Promise.reject(response.data) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (response.data.message) { | 
|---|
|  |  |  | const tm = response.data.message | 
|---|
|  |  |  | const list = tm.split(' ') | 
|---|
|  |  |  | let msg = list[0] | 
|---|
|  |  |  | if (list.length > 1 && response.data.data) { | 
|---|
|  |  |  | msg = decryptedData(list[1], list[0]) | 
|---|
|  |  |  | response.data.data = decryptedData(list[1], response.data.data) | 
|---|
|  |  |  | response.data.message = msg | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return response.data.data | 
|---|
|  |  |  | }, function (error) { | 
|---|
|  |  |  | console.log('error', error) | 
|---|