63 lines
1.7 KiB
JavaScript
63 lines
1.7 KiB
JavaScript
/**
|
|
* 项目环境配置文件
|
|
* 集中管理所有环境相关的配置参数
|
|
*/
|
|
|
|
// 开发环境配置
|
|
const development = {
|
|
// API基础URL
|
|
baseUrl: 'https://testapi.zfunbox.cn',
|
|
// 图片资源URL
|
|
imageUrl: 'https://image.zfunbox.cn',
|
|
// 登录页面URL
|
|
loginPage: 'https://testapi.zfunbox.cn/login.html',
|
|
// 微信APPID
|
|
wxAppId: 'wx0e33d80d35e4a3b1'
|
|
};
|
|
|
|
// 生产环境配置
|
|
const production = {
|
|
baseUrl: 'https://testapi.zfunbox.cn',
|
|
imageUrl: 'https://image.zfunbox.cn',
|
|
loginPage: 'https://testapi.zfunbox.cn/login.html',
|
|
wxAppId: 'wx0e33d80d35e4a3b1'
|
|
};
|
|
|
|
// 测试环境配置
|
|
const testing = {
|
|
baseUrl: 'https://testapi.zfunbox.cn',
|
|
imageUrl: 'https://image.zfunbox.cn',
|
|
loginPage: 'https://testapi.zfunbox.cn/login.html',
|
|
wxAppId: 'wx0e33d80d35e4a3b1'
|
|
};
|
|
|
|
// 根据环境变量选择对应配置
|
|
let currentEnv = development;
|
|
|
|
// 判断当前环境
|
|
// #ifdef H5
|
|
if (process.env.NODE_ENV === 'production') {
|
|
currentEnv = production;
|
|
} else if (process.env.NODE_ENV === 'testing') {
|
|
currentEnv = testing;
|
|
}
|
|
// #endif
|
|
|
|
// #ifdef MP-WEIXIN
|
|
currentEnv = production; // 小程序默认使用生产环境配置
|
|
// #endif
|
|
|
|
// 衍生配置
|
|
const config = {
|
|
...currentEnv,
|
|
// API请求完整路径
|
|
apiBaseUrl: currentEnv.baseUrl + '/api/',
|
|
// 微信登录重定向URL
|
|
wxLoginUrl: `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${currentEnv.wxAppId}&redirect_uri=${escape(currentEnv.loginPage)}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`,
|
|
// 图片资源路径
|
|
imageBaseUrl: currentEnv.imageUrl + '/static/web',
|
|
// 图标资源路径
|
|
iconBaseUrl: currentEnv.imageUrl + '/static/web/static/'
|
|
};
|
|
|
|
export default config;
|