From 08d0000f3fc136bcc41fdc910dd04d528212de5c Mon Sep 17 00:00:00 2001
From: zhouyonggao <1971162852@qq.com>
Date: Wed, 3 Dec 2025 11:54:33 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=8A=A8=E6=80=81?=
=?UTF-8?q?=E9=85=8D=E7=BD=AEAPI=E5=9F=BA=E7=A1=80URL=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
在config.js中添加全局变量__API_BASE__,并在main.js中实现优先使用配置的API基础URL,其次使用location.origin或默认值的逻辑
---
web/config.js | 1 +
web/index.html | 1 +
web/main.js | 2 +-
3 files changed, 3 insertions(+), 1 deletion(-)
create mode 100644 web/config.js
diff --git a/web/config.js b/web/config.js
new file mode 100644
index 0000000..b7be8b1
--- /dev/null
+++ b/web/config.js
@@ -0,0 +1 @@
+window.__API_BASE__ = ''
diff --git a/web/index.html b/web/index.html
index 547f89b..903b493 100644
--- a/web/index.html
+++ b/web/index.html
@@ -305,6 +305,7 @@
+
diff --git a/web/main.js b/web/main.js
index e4e6bdd..c50a4bc 100644
--- a/web/main.js
+++ b/web/main.js
@@ -37,7 +37,7 @@ const { createApp, reactive } = Vue;
exportTpl: { id: null, filters: {}, main_table: '', fields: [], datasource: '', file_format: '' }
})
- const API_BASE = 'http://localhost:8077'
+ const API_BASE = (window.__API_BASE__ && String(window.__API_BASE__).trim()) ? String(window.__API_BASE__).trim() : (typeof location !== 'undefined' ? location.origin : 'http://localhost:8077')
const getUserId = ()=>{
const sp = new URLSearchParams(window.location.search||'')
const v = sp.get('userId') || sp.get('userid') || sp.get('user_id')