Commit 33fce56e by liangjianmin

重构 API 环境配置,支持动态切换生产和开发环境

parent 4aa895c5
Showing with 29 additions and 9 deletions
const API_BASE = 'https://api.ichunt.com';
const API_BASE_OSS = 'https://image.ichunt.net'; //oss系统
const API_BASE_OSS_HK = 'http://hk.image.semour.com'; //oss系统 HK
const API_BASE_WMS = 'https://wms.ichunt.net'; //WMS系统
// 环境配置:'production' 正式环境 | 'development' 测试环境
var ENV = 'development';
// const API_BASE = 'http://api.liexin.com';
// const API_BASE_OSS = 'http://image.liexindev.net';
// const API_BASE_OSS_HK = 'http://image.liexindev.net'; //oss系统 HK
// const API_BASE_WMS = 'http://wms.liexindev.net'; //WMS系统
// 环境配置映射
var ENV_CONFIG = {
production: {
API_BASE: 'https://api.ichunt.com',
API_BASE_OSS: 'https://image.ichunt.net',
API_BASE_OSS_HK: 'http://hk.image.semour.com',
API_BASE_WMS: 'https://wms.ichunt.net'
},
development: {
API_BASE: 'http://api.liexin.com',
API_BASE_OSS: 'http://image.liexindev.net',
API_BASE_OSS_HK: 'http://image.liexindev.net',
API_BASE_WMS: 'http://wms.liexindev.net'
}
};
// 当前环境配置
var currentEnv = ENV_CONFIG[ENV];
var API_BASE = currentEnv.API_BASE;
var API_BASE_OSS = currentEnv.API_BASE_OSS;
var API_BASE_OSS_HK = currentEnv.API_BASE_OSS_HK;
var API_BASE_WMS = currentEnv.API_BASE_WMS;
const API = {
// 环境日志输出
var envText = ENV === 'production' ? '🔴 正式环境' : '🟢 测试环境';
console.log(`[环境] ${envText}`);
var API = {
/**
* 上传数据
* */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment