Logo 下移 safe-area、embed 隐藏 HTML 标题;暖色渐变铺满刘海,页面背景上延与全屏洗底层对齐。 Co-authored-by: Cursor <cursoragent@cursor.com>
26 lines
886 B
TypeScript
26 lines
886 B
TypeScript
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'
|
|
}
|