h5分享配置优化
parent
5cdaa82f83
commit
49bbe4922e
8
.env
8
.env
|
|
@ -31,9 +31,9 @@ SHOPRO_MPLIVE_ON=0
|
|||
SHOPRO_TENANT_ID=1
|
||||
|
||||
# H5 分享链接(普通浏览器使用,多个链接用逗号分隔)
|
||||
# SHOPRO_H5SHARE_URL=https://h5-1.example.com,https://h5-2.example.com
|
||||
SHOPRO_H5SHARE_URL=https://h5.example.com
|
||||
# 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_MINI_BASE_URL=https://mini-1.example.com,https://mini-2.example.com
|
||||
SHOPRO_MINI_BASE_URL=https://mini.example.com
|
||||
# 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
|
||||
|
|
@ -37,19 +37,18 @@ const parseCommaSeparatedUrls = (urls) => {
|
|||
// 获取 H5 分享链接
|
||||
// 普通浏览器:使用 SHOPRO_H5SHARE_URL
|
||||
// 小程序环境:使用 SHOPRO_MINI_BASE_URL
|
||||
export const h5shareUrl = isMiniProgram
|
||||
export let h5shareUrl = isMiniProgram
|
||||
? parseCommaSeparatedUrls(import.meta.env.SHOPRO_MINI_BASE_URL)
|
||||
: parseCommaSeparatedUrls(import.meta.env.SHOPRO_H5SHARE_URL);
|
||||
|
||||
// 确保 h5shareUrl 是完整的 URL
|
||||
if (h5shareUrl && !h5shareUrl.startsWith('http')) {
|
||||
console.warn('h5shareUrl 必须是完整的 URL,不能是路径');
|
||||
h5shareUrl = null; // 如果配置错误,设置为 null
|
||||
h5shareUrl = 'https://default-h5.example.com'; // 如果配置错误,设置为默认值
|
||||
}
|
||||
|
||||
// 调试信息
|
||||
console.log('wx:', wx);
|
||||
console.log('wx.getSystemInfoSync:', wx && wx.getSystemInfoSync);
|
||||
console.log('当前环境:', process.env.NODE_ENV);
|
||||
console.log('isMiniProgram:', isMiniProgram);
|
||||
console.log('h5shareUrl:', h5shareUrl);
|
||||
|
||||
|
|
@ -60,4 +59,4 @@ export default {
|
|||
tenantId,
|
||||
websocketPath,
|
||||
h5shareUrl,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue