// 必须在用户点击的同步调用链内调用;打开主页不代表已经关注或绑定。 export function openWechatOfficialAccount({ onUnavailable, onComplete }) { let settled = false const finish = (unavailable) => { if (settled) return settled = true try { if (unavailable) onUnavailable() } finally { onComplete() } } try { // #ifdef MP-WEIXIN if (typeof wx !== 'undefined' && typeof wx.openOfficialAccountProfile === 'function') { wx.openOfficialAccountProfile({ username: 'gh_53e43e6f5c92', success: () => finish(false), fail: () => finish(true) }) return } // #endif finish(true) } catch (error) { finish(true) } }