From 61e89d748cc7f5456c20866e672a4bde153534f1 Mon Sep 17 00:00:00 2001
From: zuoxiao <zuoxiao>
Date: 星期一, 21 四月 2025 17:18:53 +0800
Subject: [PATCH] 优化项目配置,重构项目URL管理逻辑,改为使用动态配置;更新灌溉组详情页面,添加详细信息展示和请求逻辑,提升用户体验;更新首页项目选择器,支持动态项目列表展示。

---
 api/config.js |   36 ++++++++++++------------------------
 1 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/api/config.js b/api/config.js
index 07885fe..cf4a428 100644
--- a/api/config.js
+++ b/api/config.js
@@ -1,11 +1,8 @@
-const { ENV } = require('./env')
+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/'    // 姘戝嫟椤圭洰
-  MQ: 'https://no253541tf71.vicp.fun/'    // 姘戝嫟椤圭洰
-}
 
 // 灏濊瘯浠庢湰鍦板瓨鍌ㄨ幏鍙栧凡閫夋嫨鐨勯」鐩�
 let selectedProject = 'JYG'; // 榛樿涓哄槈宄叧椤圭洰
@@ -22,7 +19,7 @@
       console.error('浠庢湰鍦板瓨鍌ㄨ幏鍙栭」鐩け璐�:', e);
     }
   }
-  
+
   // 濡傛灉鍏ㄥ眬搴旂敤宸插垵濮嬪寲锛屼篃灏濊瘯浠庡叏灞�鍙橀噺鑾峰彇
   const app = getApp();
   if (app && app.globalData && app.globalData.selectedProject) {
@@ -33,31 +30,22 @@
   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;
-}
+// 鏍规嵁鐜鍜岄」鐩缃瓸ASEURL
+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,
+  BASEURL, // 椤圭洰鎺ュ彛鍦板潃锛屾敮鎸佸鍩熷悕
   setBaseUrl
 }
\ No newline at end of file

--
Gitblit v1.8.0