From df64ac9aea00067516b2b64abad763ceb62385ff Mon Sep 17 00:00:00 2001 From: lifetime have you <121815889@qq.com> Date: Sat, 25 Jan 2025 23:33:57 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E6=8F=8F=E8=BF=B0?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=EF=BC=8C=E4=BE=BF=E4=BA=8E=E7=90=86=E8=A7=A3?= =?UTF-8?q?=202=E3=80=81=E5=A2=9E=E5=8A=A0=E6=9C=AA=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=88=86=E4=BA=AB=E9=93=BE=E6=8E=A5=E6=88=96=E8=80=85=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=87=BA=E9=94=99=EF=BC=8C=E4=BD=BF=E7=94=A8=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=9F=9F=E5=90=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 8 ++++---- sheep/config/index.js | 13 +++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.env b/.env index 9e33693a..31ee04cf 100644 --- a/.env +++ b/.env @@ -30,10 +30,10 @@ SHOPRO_MPLIVE_ON=0 # 租户ID 默认 1 SHOPRO_TENANT_ID=1 -# H5 分享链接(普通浏览器使用,多个链接用逗号分隔) +# H5 分享链接(在浏览器内复制得到的链接,多个链接用逗号分隔) # SHOPRO_H5SHARE_URL=https://h5-1.iocoder.cn,https://h5-2.iocoder.cn -SHOPRO_H5SHARE_URL=https://h5.iocoder.cn,https://h5-2.iocoder.cn +SHOPRO_H5SHARE_URL=https://h5.iocoder.cn -# 小程序 分享链接(多个链接用逗号分隔) +# 小程序 分享链接(在小程序内复制得到的链接,多个链接用逗号分隔) # SHOPRO_MINI_BASE_URL=https://mini-1.iocoder.cn,https://mini-2.iocoder.cn -SHOPRO_MINI_BASE_URL=https://mini.yudao.iocoder.cn,https://mini-2.iocoder.cn \ No newline at end of file +SHOPRO_MINI_BASE_URL=https://mini.iocoder.cn \ No newline at end of file diff --git a/sheep/config/index.js b/sheep/config/index.js index b268ae87..7940e04e 100644 --- a/sheep/config/index.js +++ b/sheep/config/index.js @@ -20,7 +20,7 @@ const isMiniProgram = typeof wx !== 'undefined' && typeof wx.getSystemInfoSync = // 解析逗号分隔的域名 const parseCommaSeparatedUrls = (urls) => { if (!urls) { - console.warn('未配置分享链接'); + console.warn('未配置分享链接,使用默认域名'); return null; } const urlList = urls @@ -28,9 +28,10 @@ const parseCommaSeparatedUrls = (urls) => { .map(url => url.trim()) // 去除空白 .filter(url => url); // 过滤空字符串 if (urlList.length === 0) { - console.warn('分享链接配置为空或无效'); + console.warn('分享链接配置为空或无效,使用默认域名'); return null; } + console.log('可用域名列表:', urlList); // 打印可用域名列表 return urlList[Math.floor(Math.random() * urlList.length)]; // 随机选择一个域名 }; @@ -38,13 +39,13 @@ const parseCommaSeparatedUrls = (urls) => { // 普通浏览器:使用 SHOPRO_H5SHARE_URL // 小程序环境:使用 SHOPRO_MINI_BASE_URL export let h5shareUrl = isMiniProgram - ? parseCommaSeparatedUrls(import.meta.env.SHOPRO_MINI_BASE_URL) - : parseCommaSeparatedUrls(import.meta.env.SHOPRO_H5SHARE_URL); + ? parseCommaSeparatedUrls(import.meta.env.SHOPRO_MINI_BASE_URL) || 'https://doc.iocoder.cn/' + : parseCommaSeparatedUrls(import.meta.env.SHOPRO_H5SHARE_URL) || 'https://doc.iocoder.cn/'; // 确保 h5shareUrl 是完整的 URL if (h5shareUrl && !h5shareUrl.startsWith('http')) { - console.warn('h5shareUrl 必须是完整的 URL,不能是路径'); - h5shareUrl = 'https://default-h5.example.com'; // 如果配置错误,设置为默认值 + console.warn('h5shareUrl 必须是完整的 URL,不能是路径,使用默认域名'); + h5shareUrl = 'https://doc.iocoder.cn/'; // 如果配置错误,设置为默认值 } // 调试信息