yingsa/miniprogram/config.js

49 lines
1.2 KiB
JavaScript

/**
* 小程序配置文件
* 请根据实际环境修改以下配置
*/
// 开发环境配置
const devConfig = {
// API 基础地址(本地开发)
baseUrl: "https://yingsa-server.ethan.team",
// WebSocket 地址(本地开发)
wsUrl: "wss://yingsa-server.ethan.team/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 = __wxConfig?.envVersion || "develop";
return envVersion === "release" ? "production" : "development";
} catch (e) {
return "development";
}
};
const env = getEnv();
const config = env === "production" ? prodConfig : devConfig;
module.exports = {
...config,
env,
// 其他配置项
// 上传文件大小限制 (MB)
uploadMaxSize: 5,
// 请求超时时间 (ms)
requestTimeout: 30000,
// 版本号
version: "1.0.0",
};