260517
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import store from '@/store'
|
||||
|
||||
// 获取合并的数据
|
||||
export const mergeConfig = (_this, options) => {
|
||||
//判断url是不是链接
|
||||
@@ -5,10 +7,14 @@ export const mergeConfig = (_this, options) => {
|
||||
let config = Object.assign({
|
||||
timeout: _this.timeout
|
||||
}, _this.config, options);
|
||||
|
||||
// 动态从 store 中获取最新的 apiUrl
|
||||
const dynamicApiUrl = store.getters.apiUrl || _this.baseUrl;
|
||||
|
||||
if (options.method == "FILE") {
|
||||
config.url = urlType ? options.url : _this.fileUrl + options.url;
|
||||
config.url = urlType ? options.url : (dynamicApiUrl || _this.fileUrl) + options.url;
|
||||
} else {
|
||||
config.url = urlType ? options.url : _this.baseUrl + options.url;
|
||||
config.url = urlType ? options.url : dynamicApiUrl + options.url;
|
||||
}
|
||||
//请求头
|
||||
if (options.header) {
|
||||
|
||||
@@ -4,16 +4,12 @@
|
||||
import store from '@/store'
|
||||
import request from './request'
|
||||
|
||||
// 后端api地址
|
||||
// const apiUrl = 'http://' + store.getters.apiUrl
|
||||
const apiUrl = 'http://ectms.dev.opmonitor.com'
|
||||
|
||||
// 可以new多个request来支持多个域名请求
|
||||
const $http = new request({
|
||||
// 接口请求地址
|
||||
baseUrl: apiUrl,
|
||||
// 服务器本地上传文件地址
|
||||
fileUrl: apiUrl,
|
||||
// 接口请求地址(初始值,实际使用时会从 store 动态读取)
|
||||
baseUrl: '',
|
||||
// 服务器本地上传文件地址(初始值,实际使用时会从 store 动态读取)
|
||||
fileUrl: '',
|
||||
// 服务器上传图片默认url
|
||||
defaultUploadUrl: 'upload/image',
|
||||
// 设置请求头(如果使用报错跨域问题,可能是content-type请求类型和后台那边设置的不一致)
|
||||
@@ -27,7 +23,7 @@ const $http = new request({
|
||||
// 是否自动提示错误
|
||||
isPrompt: true,
|
||||
// 是否显示加载动画
|
||||
load: true,
|
||||
load: false,
|
||||
// 是否使用数据工厂
|
||||
isFactory: true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user