liluo293254 11c5647ae5 feat: 统一环境配置并移除本地测试登录入口
新增 config/env.js 管理 local/test/prod 网关,清理调试登录与页面联调相关改动。
2026-08-07 08:47:52 +08:00

56 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 净水机小程序环境(仅本小程序)
*
* APP_ENV:
* local — 本机 8120需开发者工具勾选「不校验合法域名」
* test — 测试网关
* prod — 生产网关(正式版 / 体验版发版必须用 prod
*
* 静态资源:统一 https://static.hshuishang.com
*/
const APP_ENV = 'local' // local | test | prod正式/体验版必须 prod本机联调改为 local
const STATIC_URL = 'https://static.hshuishang.com'
const ALIYUN_OSS_URL = 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com'
const API = {
local: {
server_url: 'http://127.0.0.1:8120/api/v1',
api_host: 'http://127.0.0.1:8120',
},
test: {
server_url: 'https://test.hshuishang.com/api/v1',
api_host: 'https://test.hshuishang.com',
},
prod: {
server_url: 'https://api.hshuishang.com/api/v1',
api_host: 'https://api.hshuishang.com',
},
}
if (!API[APP_ENV]) {
throw new Error('config/env.js: APP_ENV must be local|test|prod, got ' + APP_ENV)
}
const api = API[APP_ENV]
const USE_LOCAL = APP_ENV === 'local'
module.exports = {
APP_ENV,
USE_LOCAL,
STATIC_URL,
CDN: {
development: { static_url: STATIC_URL, aliyun_oss_url: ALIYUN_OSS_URL },
production: { static_url: STATIC_URL, aliyun_oss_url: ALIYUN_OSS_URL },
},
ENV: {
local: { ...API.local, static_url: STATIC_URL, aliyun_oss_url: ALIYUN_OSS_URL },
test: { ...API.test, static_url: STATIC_URL, aliyun_oss_url: ALIYUN_OSS_URL },
prod: { ...API.prod, static_url: STATIC_URL, aliyun_oss_url: ALIYUN_OSS_URL },
},
server_url: api.server_url,
img_url: api.api_host,
static_url: STATIC_URL,
aliyun_oss_url: ALIYUN_OSS_URL,
}