/** * 小程序环境开关(改这一处即可切换测试 / 生产 / 本机) * * - local 本机 backend(HBuilderX / 微信开发者工具联调) * - test 测试门户 121.43.228.102:9911 * - production 生产门户 https://w.shanxiachem.com * * 发版前请改为 'production',并执行:npm run release:check-api */ export const APP_ENV = 'production' /** 微信小程序 AppID(生产正式号;测试号若不同可按环境再拆) */ export const WECHAT_MP_APPID = 'wx7db1ddb2a90c9425' /** * 环境预设(由生产 Web https://w.shanxiachem.com/ 与部署文档核对) * * | 项 | 生产实测 | * |----|----------| * | Web | https://w.shanxiachem.com/ | * | API | https://w.shanxiachem.com/api (例:/web/crm/quote/list) | * | 登录 RSA | GET /api/web/auth/login-rsa-public-key → 200 | * | 静态资源 | https://w.shanxiachem.com/shanxia-static/ | * | MinIO 反代 | https://w.shanxiachem.com/ruoyi | */ export const ENV_PRESETS = { local: { key: 'local', label: '本机', apiBaseUrl: 'http://127.0.0.1:8000/api', staticAssetsBaseUrl: 'http://121.43.228.102:9911/shanxia-static/', webOrigin: 'http://127.0.0.1:3006', minioBaseUrl: 'http://47.99.164.66:20004/zkxw' }, test: { key: 'test', label: '测试', apiBaseUrl: 'http://121.43.228.102:9911/api', staticAssetsBaseUrl: 'http://121.43.228.102:9911/shanxia-static/', webOrigin: 'http://121.43.228.102:9911', minioBaseUrl: 'http://121.43.228.102:9911/ruoyi' }, production: { key: 'production', label: '生产', apiBaseUrl: 'https://w.shanxiachem.com/api', staticAssetsBaseUrl: 'https://w.shanxiachem.com/shanxia-static/', webOrigin: 'https://w.shanxiachem.com', minioBaseUrl: 'https://w.shanxiachem.com/ruoyi' } } const preset = ENV_PRESETS[APP_ENV] || ENV_PRESETS.local export const CURRENT_ENV = preset export const IS_PRODUCTION = preset.key === 'production' export const IS_TEST = preset.key === 'test' export const IS_LOCAL = preset.key === 'local' export const API_BASE_URL = preset.apiBaseUrl export const STATIC_ASSETS_BASE_URL = preset.staticAssetsBaseUrl export const WEB_ORIGIN = preset.webOrigin export const MINIO_BASE_URL = preset.minioBaseUrl /** 每次调用按当前 APP_ENV 取值,避免热更新后 api.js 里拷贝的常量仍指向旧环境 */ export function resolveApiBase() { return (ENV_PRESETS[APP_ENV] || ENV_PRESETS.local).apiBaseUrl } export function resolveWebOrigin() { return (ENV_PRESETS[APP_ENV] || ENV_PRESETS.local).webOrigin }