Przeglądaj źródła

Refactor customsData.api.ts to use dynamic base URL for API endpoints

- Introduced BASE_URL constant to switch between production and development environments.
- Updated API endpoint URLs to utilize the BASE_URL for better flexibility and maintainability.
zq940222 3 miesięcy temu
rodzic
commit
4c0d56c501
1 zmienionych plików z 6 dodań i 2 usunięć
  1. 6 2
      src/views/adweb/data/customsData.api.ts

+ 6 - 2
src/views/adweb/data/customsData.api.ts

@@ -4,9 +4,13 @@ import md5 from 'md5';
 const API_UID = "Sw5bYYe7";  // 替换为实际的 API ID
 const API_SECRET = "j4ThjI10jiV3L3y7";  // 替换为实际的 API Secret
 
+const BASE_URL = import.meta.env.PROD 
+  ? 'https://openapi.tradesparq.com'
+  : 'http://localhost:3100/tradesparq';
+
 enum Api {
-  list = 'http://localhost:3100/tradesparq/cds_v2/old_api/record',
-  listCompanies = 'http://localhost:3100/tradesparq/cds_v2/old_api/company',
+  list = `${BASE_URL}/cds_v2/old_api/record`,
+  listCompanies = `${BASE_URL}/tes/search/company`,
 }
 
 // 定义请求参数类型