fix(h5): 修复 WebView 顶栏 logo 与内容重叠

embed 模式 header 改文档流、移除负 margin;持久化 sbh 并在路由中保留,避免胶囊区与档案条重叠。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-25 01:22:39 +08:00
co-authored by Cursor
parent 9d4fb52d29
commit f4bd57ce1b
7 changed files with 48 additions and 14 deletions
+6 -2
View File
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { initMpEmbed, isMpEmbed } from './mpEmbed'
import { applyMpEmbedDom, initMpEmbed, isMpEmbed } from './mpEmbed'
describe('mpEmbed', () => {
beforeEach(() => {
@@ -17,11 +17,15 @@ describe('mpEmbed', () => {
expect(isMpEmbed()).toBe(true)
})
it('applies status bar height from ?sbh=', () => {
it('persists 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)')
expect(sessionStorage.getItem('yxg_sbh')).toBe('47')
window.history.replaceState({}, '', '/psy/?mp=1')
applyMpEmbedDom()
expect(document.documentElement.style.getPropertyValue('--yxg-safe-top')).toBe('47px')
})
it('returns false without mp query', () => {