// 创建 http 实例 import Http from './jun_http' import config from '../config' // var switchConfig = require('../../config/jun_switchConfig') import httpEvent from './jun_httpEvent' // import Upload from './jun_upload' // baseConfig key // var keys = [ // 'baseUrl', 'testBaseUrl', 'testOnlineBaseUrl' // ] // var baseUrlkey = switchConfig.istest ? keys[1] // : switchConfig.istestonline ? keys[2] // : keys[0] // 根据配置生成 httpEvent function createHttpEvent(option){ let opt = {...httpEvent} if (!option) { return opt } else { if (option.ignores && option.ignores.length) { option.ignores.forEach((key, idx)=>{ if (opt[key]) { delete opt[key] } }) } return opt } } var http = new Http({ baseUrl: config.domain, // 使用全部 httpEvent ...createHttpEvent(), ...config, }) // 静态json用 var http2 = new Http({ // 可以更改baseUrl baseUrl: config.domain, // 不使用 afterFlow ...createHttpEvent({ ignores: ['afterFlow'] }), ...config, }) // 登录用 var http3 = new Http({ baseUrl: config.domain, // 不使用 afterFlow ...createHttpEvent({ ignores: ['beforeFlow'] }), ...config, }) // vue 安装 function install(Vue){ Vue.prototype.Req = this } export default { http, http2, http3, install, }