yingsa/miniprogram/config.js
ethanfly 7a98070af6 fix(config): Update development environment URLs for API and WebSocket
- Changed the API base URL and WebSocket URL in config.js to point to the production server instead of localhost for the development environment.
- Ensured that the configuration reflects the correct endpoints for improved connectivity during development.
2026-02-08 08:44:22 +08:00

55 lines
1.5 KiB
JavaScript

/**
* 小程序配置文件
* 请根据实际环境修改以下配置
*/
// // 开发环境配置
// const devConfig = {
// // API 基础地址(本地开发)
// baseUrl: "http://127.0.0.1:3001",
// // WebSocket 地址(本地开发)
// wsUrl: "ws://127.0.0.1:3001/ws",
// };
// 开发环境配置
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 =
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",
});