From f64693c0da5483d8670220bf3a5bf89a32e94a20 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期五, 07 十一月 2025 10:34:21 +0800
Subject: [PATCH] 解决线上打包问题

---
 web/src/utils/appConfig.js |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/web/src/utils/appConfig.js b/web/src/utils/appConfig.js
index 48c75f0..72b8a12 100644
--- a/web/src/utils/appConfig.js
+++ b/web/src/utils/appConfig.js
@@ -1,25 +1,54 @@
 import { graphqlRequest } from '../config/api.ts';
 
+export const serverUrl =
+  (typeof window !== 'undefined' && window.__APP_SERVER_URL__) ||
+  (typeof import.meta !== 'undefined' && import.meta.env && import.meta.env.VITE_SERVER_URL) ||
+  'http://139.155.104.10:8080';
+
+
+
 const GET_APP_CONFIG = `
+
   query AppConfig {
+
     appConfig {
+
       mediaBaseUrl
+
     }
+
   }
+
 `;
 
+
+
 export async function loadAppConfig() {
+
   try {
+
     const result = await graphqlRequest(GET_APP_CONFIG);
+
     const mediaBaseUrl = result.data?.appConfig?.mediaBaseUrl || '';
+
     // 浣滀负鍏ㄥ眬鍙橀噺鏆撮湶
+
     window.__APP_MEDIA_BASE_URL__ = mediaBaseUrl;
+
     return mediaBaseUrl;
+
   } catch (e) {
+
     // 濡傛灉GraphQL鏌ヨ澶辫触锛屼娇鐢ㄩ粯璁ら厤缃�
+
     console.warn('loadAppConfig failed, using default config:', e?.message || e);
-    const defaultMediaBaseUrl = 'http://localhost:8080';
+
+    const defaultMediaBaseUrl = serverUrl;
+
     window.__APP_MEDIA_BASE_URL__ = defaultMediaBaseUrl;
+
     return defaultMediaBaseUrl;
+
   }
+
 }
\ No newline at end of file

--
Gitblit v1.8.0