parent
49bbe4922e
commit
df64ac9aea
8
.env
8
.env
|
|
@ -30,10 +30,10 @@ SHOPRO_MPLIVE_ON=0
|
||||||
# 租户ID 默认 1
|
# 租户ID 默认 1
|
||||||
SHOPRO_TENANT_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-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-1.iocoder.cn,https://mini-2.iocoder.cn
|
||||||
SHOPRO_MINI_BASE_URL=https://mini.yudao.iocoder.cn,https://mini-2.iocoder.cn
|
SHOPRO_MINI_BASE_URL=https://mini.iocoder.cn
|
||||||
|
|
@ -20,7 +20,7 @@ const isMiniProgram = typeof wx !== 'undefined' && typeof wx.getSystemInfoSync =
|
||||||
// 解析逗号分隔的域名
|
// 解析逗号分隔的域名
|
||||||
const parseCommaSeparatedUrls = (urls) => {
|
const parseCommaSeparatedUrls = (urls) => {
|
||||||
if (!urls) {
|
if (!urls) {
|
||||||
console.warn('未配置分享链接');
|
console.warn('未配置分享链接,使用默认域名');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const urlList = urls
|
const urlList = urls
|
||||||
|
|
@ -28,9 +28,10 @@ const parseCommaSeparatedUrls = (urls) => {
|
||||||
.map(url => url.trim()) // 去除空白
|
.map(url => url.trim()) // 去除空白
|
||||||
.filter(url => url); // 过滤空字符串
|
.filter(url => url); // 过滤空字符串
|
||||||
if (urlList.length === 0) {
|
if (urlList.length === 0) {
|
||||||
console.warn('分享链接配置为空或无效');
|
console.warn('分享链接配置为空或无效,使用默认域名');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
console.log('可用域名列表:', urlList); // 打印可用域名列表
|
||||||
return urlList[Math.floor(Math.random() * urlList.length)]; // 随机选择一个域名
|
return urlList[Math.floor(Math.random() * urlList.length)]; // 随机选择一个域名
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -38,13 +39,13 @@ const parseCommaSeparatedUrls = (urls) => {
|
||||||
// 普通浏览器:使用 SHOPRO_H5SHARE_URL
|
// 普通浏览器:使用 SHOPRO_H5SHARE_URL
|
||||||
// 小程序环境:使用 SHOPRO_MINI_BASE_URL
|
// 小程序环境:使用 SHOPRO_MINI_BASE_URL
|
||||||
export let h5shareUrl = isMiniProgram
|
export let h5shareUrl = isMiniProgram
|
||||||
? parseCommaSeparatedUrls(import.meta.env.SHOPRO_MINI_BASE_URL)
|
? parseCommaSeparatedUrls(import.meta.env.SHOPRO_MINI_BASE_URL) || 'https://doc.iocoder.cn/'
|
||||||
: parseCommaSeparatedUrls(import.meta.env.SHOPRO_H5SHARE_URL);
|
: parseCommaSeparatedUrls(import.meta.env.SHOPRO_H5SHARE_URL) || 'https://doc.iocoder.cn/';
|
||||||
|
|
||||||
// 确保 h5shareUrl 是完整的 URL
|
// 确保 h5shareUrl 是完整的 URL
|
||||||
if (h5shareUrl && !h5shareUrl.startsWith('http')) {
|
if (h5shareUrl && !h5shareUrl.startsWith('http')) {
|
||||||
console.warn('h5shareUrl 必须是完整的 URL,不能是路径');
|
console.warn('h5shareUrl 必须是完整的 URL,不能是路径,使用默认域名');
|
||||||
h5shareUrl = 'https://default-h5.example.com'; // 如果配置错误,设置为默认值
|
h5shareUrl = 'https://doc.iocoder.cn/'; // 如果配置错误,设置为默认值
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调试信息
|
// 调试信息
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue