- Updated the environment determination logic in config.js to accurately return "development" or "production" based on the current environment. - Enabled URL check in project.private.config.json to enhance security and validation of URLs.
47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
/**
|
|
* 小程序配置文件
|
|
* 请根据实际环境修改以下配置
|
|
*/
|
|
|
|
// 开发环境配置
|
|
const devConfig = {
|
|
// API 基础地址(本地开发)
|
|
baseUrl: "http://127.0.0.1:3001",
|
|
// WebSocket 地址(本地开发)
|
|
wsUrl: "ws://127.0.0.1:3001/ws",
|
|
};
|
|
|
|
// 生产环境配置
|
|
const prodConfig = {
|
|
// API 基础地址(生产环境,请替换为实际域名)
|
|
baseUrl: "https://yingsa-server.ethan.team",
|
|
// WebSocket 地址(生产环境,请替换为实际域名)
|
|
wsUrl: "wss://yingsa-server.ethan.team/ws",
|
|
};
|
|
|
|
// 根据环境变量选择配置
|
|
// 小程序可以通过 __wxConfig.envVersion 获取当前环境
|
|
// develop: 开发版, trial: 体验版, release: 正式版
|
|
const getEnv = () => {
|
|
try {
|
|
// 尝试获取微信环境
|
|
const envVersion =
|
|
typeof __wxConfig !== "undefined" && __wxConfig && __wxConfig.envVersion
|
|
? __wxConfig.envVersion
|
|
: "develop";
|
|
return envVersion == "develop" ? "development" : "production";
|
|
} catch (e) {
|
|
return "development";
|
|
}
|
|
};
|
|
|
|
const env = getEnv();
|
|
const config = env === "production" ? prodConfig : devConfig;
|
|
|
|
module.exports = Object.assign({}, config, {
|
|
env,
|
|
uploadMaxSize: 5,
|
|
requestTimeout: 30000,
|
|
version: "1.0.0",
|
|
});
|