|
|
@@ -7,24 +7,25 @@ const isDev = process.env.NODE_ENV === 'development'; // 开发 or 生产 |
|
|
|
|
|
|
|
// 匹配接口前缀 |
|
|
|
export function autoMatch (prefix) { |
|
|
|
let baseUrl = `/${prefix || 'fumao'}`; |
|
|
|
// if (isDev) { |
|
|
|
// // 开发环境 通过proxy配置转发请求; |
|
|
|
// baseUrl = `/${prefix || 'fumao'}`; |
|
|
|
// } else { |
|
|
|
// // 生产环境 根据实际配置 根据 prefix 匹配url; |
|
|
|
// // 配置来源 根据实际应用场景更改配置。(1.从全局读取;2.线上配置中心读取) |
|
|
|
// switch (prefix) { |
|
|
|
// case 'baidu': |
|
|
|
// baseUrl = window.LOCAL_CONFIG.baidu; |
|
|
|
// break; |
|
|
|
// case 'alipay': |
|
|
|
// baseUrl = window.LOCAL_CONFIG.alipay; |
|
|
|
// break; |
|
|
|
// default: |
|
|
|
// baseUrl = window.LOCAL_CONFIG.default; |
|
|
|
// } |
|
|
|
// } |
|
|
|
let baseUrl = ``; |
|
|
|
if (isDev) { |
|
|
|
// 开发环境 通过proxy配置转发请求; |
|
|
|
baseUrl = `/${prefix || 'fumao'}`; |
|
|
|
} else { |
|
|
|
// 生产环境 根据实际配置 根据 prefix 匹配url; |
|
|
|
// 配置来源 根据实际应用场景更改配置。(1.从全局读取;2.线上配置中心读取) |
|
|
|
// switch (prefix) { |
|
|
|
// case 'baseurl': |
|
|
|
// baseUrl = window.LOCAL_CONFIG.baseurl; |
|
|
|
// break; |
|
|
|
// case 'fumao': |
|
|
|
// baseUrl = window.LOCAL_CONFIG.fumao; |
|
|
|
// break; |
|
|
|
// default: |
|
|
|
// baseUrl = window.LOCAL_CONFIG.default; |
|
|
|
// } |
|
|
|
baseUrl = `/${prefix || 'fumao'}`; |
|
|
|
} |
|
|
|
return baseUrl; |
|
|
|
} |
|
|
|
|
|
|
|