| | |
| | | } from './interceptor-handler' |
| | | import { |
| | | showFullScreenLoading |
| | | } from '../utils/loading' |
| | | // import { getStorage } from '@utils/storage' |
| | | } from '@/utils/loading' |
| | | |
| | | // URL 记录器 |
| | | import urlRecorder from './url-recorder' |
| | | |
| | | const axiosInstance = axios.create({ |
| | | // baseURL: `${process.env.VUE_APP_API_BASE_URL}`, |
| | | timeout: 1000 * 60 * 5 |
| | | }) |
| | | |
| | |
| | | url: addVersion(url), |
| | | params, |
| | | errorHandler: (!throwError && this.defaultErrorHandler) || null, |
| | | // headers: { 'Content-Type': 'application/json', token: thisToken }, |
| | | headers: { |
| | | 'Content-Type': 'application/json' |
| | | }, |
| | |
| | | * 通过post发送数据,使后端直接收到json格式的数据。并统一处理常见的错误 |
| | | * @param {string} url |
| | | * @param {object?} data={} |
| | | * @param {object} params={} |
| | | * @param {boolean?} throwError 是否不使用默认的异常处理方法,而把异常抛出来 |
| | | * @param {int?} timeout 超时时间,默认10秒 |
| | | * @return {Promise} 返回一个promise对象。其中then方法传递回包中的data数据;catch事件则传递整个回包,其参数为{data:{},status{code:123,message:'xxx'}} |
| | | */ |
| | | post(url, data = {}, throwError) { |
| | | post(url, data = {}, params = {}, throwError) { |
| | | const config = { |
| | | method: 'POST', |
| | | url, |
| | | params, |
| | | data: JSON.stringify(data), |
| | | errorHandler: (!throwError && this.defaultErrorHandler) || null, |
| | | headers: { |