const MP_EMBED_KEY = 'yxg_mp_embed' const MP_QUERY = 'mp' /** Apply document-level embed chrome (safe-area wash, hide HTML title). */ export function applyMpEmbedDom(): void { if (typeof document === 'undefined' || !isMpEmbed()) return document.title = '\u200b' document.documentElement.classList.add('mp-embed') } /** Persist ?mp=1 from mini-program web-view entry. Call once before router mount. */ export function initMpEmbed(): void { if (typeof window === 'undefined') return const params = new URLSearchParams(window.location.search) if (params.get(MP_QUERY) === '1') { sessionStorage.setItem(MP_EMBED_KEY, '1') } applyMpEmbedDom() } /** True when H5 runs inside WeChat mini-program web-view (no H5 tab bar). */ export function isMpEmbed(): boolean { if (typeof window === 'undefined') return false return sessionStorage.getItem(MP_EMBED_KEY) === '1' }