Files
zkxw/mobile-h5/utils/config.js
T
zlwuandCursor a47a7db7dc feat(mobile-h5): export ENV_BANNER from APP_ENV
Add buildEnvBanner so the homepage can show a non-prod
stripe without hardcoding environment labels.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-11 10:01:42 +08:00

69 lines
2.4 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.
/**
* 运行环境开关(改这一处即可切换)
* - local:本机联调(模拟器 / 同网手机)
* - test :测试机 www.chengyantek.cn(体验版联调测试后端)
* - prod :生产 xwyd.zkxw.cn(正式/体验版连生产)
*
* 微信公众平台须为对应环境配置 request / 业务域名(HTTPS)
*/
export const APP_ENV = 'local' // 'local' | 'test' | 'prod'
const ENV_PRESETS = {
local: {
apiBaseUrl: 'http://127.0.0.1:8000/api',
/** 本机 OA H5(Vite);真机同网时把 IP 改成电脑局域网地址 */
oaH5Origin: 'http://127.0.0.1:5178/oa-h5',
/** 与 web-admin `.env.development` 的 VITE_MINIO_BASE_URL 对齐 */
minioBaseUrl: 'http://47.99.164.66:20004/zkxw',
/** 测试服务号原始 ID(本地联调可沿用测试号) */
mpGhUsername: 'gh_e0b5daf10934'
},
test: {
apiBaseUrl: 'https://www.chengyantek.cn/api',
oaH5Origin: 'https://www.chengyantek.cn/oa-h5',
minioBaseUrl: 'https://www.chengyantek.cn/minio/zkxw',
mpGhUsername: 'gh_e0b5daf10934'
},
prod: {
apiBaseUrl: 'https://xwyd.zkxw.cn/api',
oaH5Origin: 'https://xwyd.zkxw.cn/oa-h5',
minioBaseUrl: 'https://xwyd.zkxw.cn/minio/zkxw',
mpGhUsername: 'gh_4d29bb37922f'
}
}
const preset = ENV_PRESETS[APP_ENV] || ENV_PRESETS.prod
/** 后端 API 根路径(含 /api,不含末尾斜杠) */
export const API_BASE_URL = preset.apiBaseUrl
export const REQUEST_TIMEOUT_MS = 15000
/** OA 表单 H5 源(web-view) */
export const OA_H5_ORIGIN = preset.oaH5Origin
/** MinIO 公网/反代基址(不含末尾斜杠);附件相对 key 需拼此前缀 */
export const MINIO_BASE_URL = preset.minioBaseUrl
/** 服务号原始 ID(gh_…),用于 openOfficialAccountProfile */
export const MP_GH_USERNAME = preset.mpGhUsername
/** 关注二维码图片(兜底) */
export const MP_QRCODE_URL = '/static/mp-qrcode.png'
/** 绑定 H5 路径(相对 OA_H5_ORIGIN) */
export const MP_BIND_H5_PATH = '/oa-mp-bind/'
/** 首页非生产环境色条描述(prod / 未知值不展示) */
export function buildEnvBanner(appEnv) {
if (appEnv === 'local') {
return { show: true, label: '本地环境', tone: 'local' }
}
if (appEnv === 'test') {
return { show: true, label: '测试环境', tone: 'test' }
}
return { show: false, label: '', tone: '' }
}
export const ENV_BANNER = buildEnvBanner(APP_ENV)