| | |
| | | const { |
| | | ENV |
| | | } = require('./env') |
| | | const { PROJECT_CONFIG } = require('../utils/projectConfig') |
| | | let BASEURL |
| | | |
| | | const PROJECT_URLS = { |
| | | JYG: 'https://irrigate.dayuyanjiuyuan.top/', // 嘉峪关项目 |
| | | MQ: 'https://shifanqu1.dayuyanjiuyuan.top/', // 民勤项目 |
| | | TEST: 'https://no253541tf71.vicp.fun/', // test项目 |
| | | SCHOOL: 'https://school.dayuyanjiuyuan.top/', // 学校项目 |
| | | JC:'https://shifanqu1.dayuyanjiuyuan.top/', |
| | | GSCLT:'https://irrigate.dayuyanjiuyuan.top/'//甘肃农科院崔龙天 |
| | | // TEST:'http://192.168.40.182:8087/'// test项目 |
| | | // MQ: 'https://no253541tf71.vicp.fun/' // 民勤项目 |
| | | // TEST: 'http://192.168.40.166:54321/' |
| | | } |
| | | |
| | | // 尝试从本地存储获取已选择的项目 |
| | | let selectedProject = 'JYG'; // 默认为嘉峪关项目 |
| | |
| | | console.error('获取已选择项目失败:', e); |
| | | } |
| | | |
| | | switch (ENV) { |
| | | case 'production': |
| | | BASEURL = PROJECT_URLS[selectedProject] || PROJECT_URLS.JYG; |
| | | break; |
| | | case 'test': |
| | | // BASEURL 将根据用户选择的项目动态设置 |
| | | BASEURL = PROJECT_URLS[selectedProject] || PROJECT_URLS.JYG; |
| | | break; |
| | | default: |
| | | BASEURL = PROJECT_URLS[selectedProject] || PROJECT_URLS.JYG; |
| | | break; |
| | | } |
| | | // 根据环境和项目设置BASEURL |
| | | BASEURL = PROJECT_CONFIG[selectedProject]?.serverUrl || PROJECT_CONFIG.JYG.serverUrl; |
| | | |
| | | // 导出动态设置 BASEURL 的函数 |
| | | function setBaseUrl(project) { |
| | | if (PROJECT_URLS[project]) { |
| | | BASEURL = PROJECT_URLS[project]; |
| | | const serverUrl = PROJECT_CONFIG[project]?.serverUrl; |
| | | if (serverUrl) { |
| | | BASEURL = serverUrl; |
| | | console.log('动态设置 BASEURL:', BASEURL); |
| | | return true; |
| | | } |
| | | console.error('项目配置不存在或未设置服务器地址:', project); |
| | | return false; |
| | | } |
| | | |
| | | module.exports = { |
| | | BASEURL, // 项目接口地址,支持多域名 |
| | | PROJECT_URLS, |
| | | setBaseUrl |
| | | } |