| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- /**
- * 应用全局配置
- *
- * 环境切换方式:
- * 1. 开发环境(默认):从 VUE_APP_API_BASE 环境变量读取,或回退到默认值
- * 2. 测试环境:配置 VUE_APP_API_BASE=https://test-api.xxx.com
- * 3. 生产环境:配置 VUE_APP_API_BASE=https://api.xxx.com
- *
- * uni-app vue-cli 项目通过 .env 文件设置环境变量:
- * .env.development — VUE_APP_API_BASE=http://localhost:9080
- * .env.production — VUE_APP_API_BASE=https://api.xxx.com
- * .env.staging — VUE_APP_API_BASE=https://staging-api.xxx.com
- *
- * 如果未配置环境变量,默认使用开发环境地址。
- */
- // #ifndef VUE_APP_API_BASE
- const API_BASE_URL = process.env.VUE_APP_API_BASE || 'http://localhost:9080'
- // #endif
- // #ifdef VUE_APP_API_BASE
- const API_BASE_URL = VUE_APP_API_BASE
- // #endif
- // DAN测评服务(独立服务,可能不同端口)
- const DANSHOP_BASE_URL = process.env.VUE_APP_DANSHOP_BASE || 'http://localhost:8081'
- export default {
- API_BASE_URL,
- DANSHOP_BASE_URL,
- /** 构建 API 完整 URL */
- api(path) {
- return API_BASE_URL + path
- },
- /** 构建 DAN 测评 API URL */
- danshop(path) {
- return DANSHOP_BASE_URL + path
- }
- }
|