Files
shanxia2.0/miniprogram/config/env.js
T
2026-09-26 11:59:39 +08:00

85 lines
3.1 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.
/**
* 小程序环境开关 —— **只改这一处** 即可切换本机 / 测试 / 生产 / 本机联调 H5
*
* | APP_ENV 值 | 用途 |
* |------------------|------|
* | `local` | 本机 backend + 本机 web-admin |
* | `test` | 测试门户(API / H5 / 静态 均 9911) |
* | `testLocalH5` | 测试 API + 本机 H5(仅联调 webview 样式;需本机 `pnpm dev` 且代理到测试 API) |
* | `production` | 生产门户 https://w.shanxiachem.com |
*
* 上生产:改成 `export const APP_ENV = '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 |
* | 静态资源 | 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'
},
/** 测试业务数据 + 本机 H5 资源(改样式时用,不用于发测试包) */
testLocalH5: {
key: 'testLocalH5',
label: '测试API+本机H5',
apiBaseUrl: 'http://121.43.228.102:9911/api',
staticAssetsBaseUrl: 'http://121.43.228.102:9911/shanxia-static/',
webOrigin: 'http://127.0.0.1:3006',
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_TEST_LOCAL_H5 = preset.key === 'testLocalH5'
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
}