优化:支持控制是否显示

This commit is contained in:
iqudoo
2026-04-30 11:17:05 +08:00
parent 8ebe8b0b34
commit f3c0856506
11 changed files with 142 additions and 26 deletions

View File

@@ -45,9 +45,12 @@ function loadWxScript() {
function fetchWxConfig() {
let initWechatJssdk = toAny(getConfig("initWechatJssdk"), {});
if (!!initWechatJssdk.sdkConfig) {
return Promise.resolve(toAny(initWechatJssdk.sdkConfig, {}));
}
let apiUrl = toAny(initWechatJssdk.apiUrl, "");
if (!apiUrl) {
return Promise.reject(new Error("initWechatJssdk.apiUrl is required, but not found"));
return Promise.reject(new Error("initWechatJssdk.apiUrl or initWechatJssdk.sdkConfig is required, but not found"));
}
return request({
url: apiUrl,
@@ -61,7 +64,7 @@ function fetchWxConfig() {
return null;
}
if (data.code !== 0) {
throw new Error(data.msg || "wx config fetch failed");
throw new Error(data.msg || "wechat jssdk config fetch failed");
}
if (data.data) {
return data.data;
@@ -94,10 +97,10 @@ export function initWxJssdk() {
const wx = items[0];
const config = items[1];
if (!wx || !wx.config) {
throw new Error("wx jssdk is not ready");
throw new Error("wechat jssdk is not ready");
}
if (!config) {
throw new Error("wx config is empty");
throw new Error("wechat jssdk config is empty");
}
const jsApiList = config.jsApiList || [];
if (jsApiList.indexOf(WX_SCAN_API) === -1) {