feat: 支持关卡配置分享
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user