From 9a11bff3d98aea29f37abc34a00a17f5c92ade9c Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期四, 02 四月 2026 17:50:36 +0800
Subject: [PATCH] fix: 扫码路径ip修改
---
src/utils/settingMer.js | 32 ++++++++++++++++++++++++++------
1 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/src/utils/settingMer.js b/src/utils/settingMer.js
index e2d59f4..730a127 100644
--- a/src/utils/settingMer.js
+++ b/src/utils/settingMer.js
@@ -8,16 +8,36 @@
// | Author: CMS Team <admin@CMS.com>
// +----------------------------------------------------------------------
-// 璇锋眰鎺ュ彛鍦板潃 濡傛灉娌℃湁閰嶇疆鑷姩鑾峰彇褰撳墠缃戝潃璺緞
-const VUE_APP_API_URL = process.env.VUE_APP_BASE_API || `${location.origin}`
-const VUE_APP_WS_URL = process.env.VUE_APP_WS_URL || (location.protocol === 'https' ? 'wss' : 'ws') + ':' + location.hostname
+// 璇锋眰鎺ュ彛鍦板潃
+// 璇存槑锛氱敓浜х幆澧冧笅涓嶅笇鏈涗娇鐢ㄢ�滃綋鍓嶅墠绔鍙b�濓紝鑰屽簲鐩存帴璧板悗绔鍙� 9031銆�
+const DEFAULT_API_PORT = process.env.VUE_APP_API_PORT || 9031;
+
+const VUE_APP_API_URL =
+ process.env.VUE_APP_BASE_API ||
+ (typeof location !== "undefined"
+ ? `${location.protocol}//${location.hostname}:${DEFAULT_API_PORT}`
+ : `http://127.0.0.1:${DEFAULT_API_PORT}`);
+
+// 鏀寔鐢ㄦ埛浼犲叆鐨� VUE_APP_BASE_API 宸茬粡鍖呭惈 /api 鐨勬儏鍐碉紝閬垮厤鎷兼垚鍙� /api
+const apiBaseURL = VUE_APP_API_URL.includes("/api")
+ ? VUE_APP_API_URL.endsWith("/") ? VUE_APP_API_URL : `${VUE_APP_API_URL}/`
+ : `${VUE_APP_API_URL.replace(/\/+$/, "")}/api/`;
+
+const VUE_APP_WS_URL =
+ process.env.VUE_APP_WS_URL ||
+ (typeof location !== "undefined"
+ ? `${
+ location.protocol === "https" ? "wss" : "ws"
+ }://${location.hostname}:${DEFAULT_API_PORT}`
+ : `ws://127.0.0.1:${DEFAULT_API_PORT}`);
+
const SettingMer = {
// 鏈嶅姟鍣ㄥ湴鍧�
httpUrl: VUE_APP_API_URL,
// 鎺ュ彛璇锋眰鍦板潃
- apiBaseURL: VUE_APP_API_URL + '/api/',
+ apiBaseURL,
// socket杩炴帴
- wsSocketUrl: VUE_APP_WS_URL
-}
+ wsSocketUrl: VUE_APP_WS_URL,
+};
export default SettingMer
--
Gitblit v1.9.3