124 lines
3.7 KiB
JavaScript
124 lines
3.7 KiB
JavaScript
// 发行版本,配置说明
|
||
let releaseCfg = undefined;
|
||
|
||
// #ifdef APP-PLUS || MP-WEIXIN || MP-ALIPAY || MP-BAIDU || MP-QQ || MP-TOUTIAO
|
||
try {
|
||
if (site) { // 从site.js文件中获取配置, 针对微信小程序类
|
||
releaseCfg = {
|
||
baseUrl: site.baseUrl,
|
||
imgDomain: site.baseUrl,
|
||
h5Domain: site.baseUrl,
|
||
uniacid: site.uniacid,
|
||
}
|
||
} else {
|
||
console.warn('小程序发行环境下,必须配置site.js文件, 不然将使用默认配置,影响小程序定制分发!');
|
||
}
|
||
} catch (e) {}
|
||
// #endif
|
||
|
||
// 线上版本部署域名, 注意: 必须以 '/' 结尾,适用于小程序/H5/快应用等场景
|
||
// 默认域名, 自定义发行时可以修改
|
||
let defaultDomain = '';
|
||
|
||
// #ifdef H5_XCX_5G_QUICKAPP_COM
|
||
defaultDomain = 'https://xcx20.5g-quickapp.com';
|
||
// #endif
|
||
|
||
// #ifdef H5_XCX_AIGC_QUICKAPP_COM
|
||
defaultDomain = 'https://xcx.aigc-quickapp.com/';
|
||
// #endif
|
||
|
||
// #ifdef H5_5G_AIGC_QUICKAPP_COM
|
||
defaultDomain = 'https://5g.aigc-quickapp.com/';
|
||
// #endif
|
||
|
||
// #ifdef H5_TEST_AIGC_QUICKAPP_COM
|
||
defaultDomain = 'https://test.aigc-quickapp.com/';
|
||
// #endif
|
||
|
||
// 确保域名以 '/' 结尾
|
||
if (defaultDomain && !defaultDomain.endsWith('/')) {
|
||
defaultDomain += '/';
|
||
}
|
||
|
||
// 本地调试配置示例文件
|
||
// 复制.local.config.js.example 并重命名为 .local.config.js 以使用自定义本地配置
|
||
let localDevConfig = { uniacid: 0, domain: defaultDomain };
|
||
|
||
// #ifndef PRODUCTION
|
||
// 尝试动态加载本地配置文件
|
||
if (process?.env?.NODE_ENV === 'development') {
|
||
try {
|
||
// 尝试从项目根目录加载本地配置文件
|
||
// 使用相对路径的方式,确保在不同平台下都能正确解析
|
||
let customConfig = require('@/.local.config.js').default;
|
||
if (customConfig) {
|
||
localDevConfig = customConfig;
|
||
}
|
||
} catch (e) {
|
||
// 如果本地配置文件不存在或加载失败,保持使用默认配置
|
||
// 只在开发模式下输出提示信息
|
||
// #ifdef WEB
|
||
console.log('本地配置文件 .local.config.js 不存在,使用默认配置');
|
||
// #endif
|
||
}
|
||
}
|
||
// #endif
|
||
|
||
const { uniacid = 0, domain = defaultDomain } = localDevConfig ?? { uniacid: 0, domain: defaultDomain }
|
||
|
||
export default {
|
||
/**
|
||
* 1.开发调试模式
|
||
* 去掉注释 ...defaultCfg;
|
||
* 注释掉 ...releaseCfg,
|
||
* 2.发行/发布模式,例如通过`HBuilder>发行>小程序微信`的时候,原理是:
|
||
* 然后将 `import site from "../site.js";`追加到 `unpackage\dist\build\mp-weixin\common\vendor.js` 文件内容开头部分
|
||
* 然后将 site.js 文件放到 `unpackage\dist\build\mp-weixin\` 目录下面
|
||
*/
|
||
// 商户ID
|
||
uniacid: uniacid, //825
|
||
|
||
//api请求地址
|
||
baseUrl: domain,
|
||
|
||
// 图片域名
|
||
imgDomain: domain,
|
||
|
||
// H5端域名
|
||
h5Domain: domain,
|
||
|
||
// // api请求地址
|
||
// baseUrl: 'https://tsaas.liveplatform.cn/',
|
||
|
||
// // 图片域名
|
||
// imgDomain: 'https://tsaas.liveplatform.cn/',
|
||
|
||
// // H5端域名
|
||
// h5Domain: 'https://tsaas.liveplatform.cn/',
|
||
|
||
// api请求地址
|
||
// baseUrl: 'http://saas.cn/',
|
||
|
||
// // 图片域名
|
||
// imgDomain: 'http://saas.cn/',
|
||
|
||
// // H5端域名
|
||
// h5Domain: 'http://saas.cn/',
|
||
|
||
// 发行版本配置
|
||
...(releaseCfg || {}),
|
||
|
||
|
||
// 腾讯地图key
|
||
mpKey: 'TUHBZ-CNWKU-UHAVP-GZQ26-HNZFO-3YBF4',
|
||
|
||
// 客服地址
|
||
webSocket: '{{$webSocket}}',
|
||
|
||
// 本地端主动给服务器ping的时间, 0 则不开启 , 单位秒
|
||
pingInterval: 1500,
|
||
|
||
// 版本号
|
||
version: '1.0'
|
||
}; |