From a0c8d6f7edcf1ed52d19674997bf57b580ec6bdc Mon Sep 17 00:00:00 2001 From: ljx <864490211@qq.com> Date: Sun, 27 Apr 2025 16:55:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=B0=83=E7=94=A8=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/baozuo-demo/test.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/components/baozuo-demo/test.js b/src/components/baozuo-demo/test.js index 3f5fe79..381cc88 100644 --- a/src/components/baozuo-demo/test.js +++ b/src/components/baozuo-demo/test.js @@ -1,4 +1,5 @@ -const testRes = { +import api from '../../api.js' +let testRes = { "code": "200", "data": { "yx_v_scgdgk": [ @@ -3196,5 +3197,26 @@ const testRes = { ] } } +/** + * 获取当前地址 + * @returns {string} 当前地址 + */ +function getCurrentAddress() { + if (typeof window !== 'undefined' && window.location) { + return window.location.origin; + } else { + console.warn('当前环境非浏览器环境,无法使用 window.location 获取地址'); + return null; + } +} +if(getCurrentAddress().includes('192.168')){ + console.log('当前环境为开发环境'); + api.post2('/api/web/getBiData').then(res => { + testRes = res; + }) +}else{ + console.log('当前环境为生产环境'); +} + export default testRes \ No newline at end of file