fix(h5): 小程序 WebView 通过 sbh 参数铺满刘海区

WebView 内 safe-area-inset-top 常为 0,改由小程序传入 statusBarHeight;
全屏洗底层上延并同步原生页背景色,修复刘海露白。
This commit is contained in:
jackyu66git
2026-08-25 01:18:16 +08:00
parent 96292d0e95
commit 9d4fb52d29
4 changed files with 35 additions and 3 deletions
+7
View File
@@ -17,6 +17,13 @@ describe('mpEmbed', () => {
expect(isMpEmbed()).toBe(true)
})
it('applies status bar height from ?sbh=', () => {
window.history.replaceState({}, '', '/psy/?mp=1&sbh=47')
initMpEmbed()
expect(document.documentElement.style.getPropertyValue('--yxg-safe-top')).toBe('47px')
expect(document.documentElement.style.getPropertyValue('--yxg-page-top')).toBe('calc(47px + 50px)')
})
it('returns false without mp query', () => {
initMpEmbed()
expect(isMpEmbed()).toBe(false)