feat: 支持关卡配置分享

This commit is contained in:
richarjiang
2026-04-06 17:32:32 +08:00
parent c7f52ab032
commit b489ab40f5
8 changed files with 392 additions and 24 deletions

View File

@@ -216,4 +216,24 @@ export class WxSDK {
}
});
}
/**
* 从启动参数中获取分享码
* @returns 分享码,不存在则返回 null
*/
static getShareCodeFromLaunch(): string | null {
const wxApi = WxSDK.getWx();
if (!wxApi) return null;
try {
const options = wxApi.getLaunchOptionsSync();
if (options?.query?.shareCode) {
console.log('[WxSDK] 检测到分享码:', options.query.shareCode);
return options.query.shareCode;
}
} catch (err) {
console.warn('[WxSDK] 获取启动参数失败:', err);
}
return null;
}
}