export function isMp() { if (typeof globalThis === 'undefined') { return false } const { wx } = globalThis as any if (typeof wx === 'undefined') { return false } if ((globalThis as any).Page === undefined) { return false } if (!wx.getDeviceInfo) { return false } if (!wx.getStorageSync) { return false } if (!wx.setStorageSync) { return false } if (!wx.connectSocket) { return false } if (!wx.request) { return false } try { if (!wx.getDeviceInfo()) { return false } if (wx.getDeviceInfo().platform === 'qq') { return false } } catch (e) { return false } return true } let IS_IN_MP_WEBVIEW = false function ready() { IS_IN_MP_WEBVIEW = IS_IN_MP_WEBVIEW || (typeof window !== undefined && (window as any).__wxjs_environment === 'miniprogram') } try { if (!isMp()) { IS_IN_MP_WEBVIEW = IS_IN_MP_WEBVIEW || !!navigator.userAgent.match(/miniprogram/i) || (window as any).__wxjs_environment === 'miniprogram' if ((window as any) && (window as any).WeixinJSBridge && (window as any).WeixinJSBridge.invoke) { ready() } else if (typeof document !== 'undefined') { document.addEventListener('WeixinJSBridgeReady', ready, false) } } } catch (e) {} export function isInMpWebView() { return IS_IN_MP_WEBVIEW }