Fix Douyin nav header: fixed topbar outside ScrollView.

Sticky headers inside ScrollView sit under the status bar on tt; move brand bar to fixed + content paddingTop.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
eric 2026-09-30 15:21:52 +08:00
parent 1d3e513ae2
commit e5a6561fa7
2 changed files with 91 additions and 63 deletions

View File

@ -23,10 +23,13 @@
gap: 8px;
}
/* 顶栏安全区由 inline(statusBar + headerHeight)控制;这里只清掉 navmini 默认 padding */
.navmini-page .topbar.sticky-stack {
/* 抖音:顶栏 fixed,清掉 navmini 默认 padding */
.navmini-page .topbar.sticky-stack,
.navmini-page .topbar--tt-fixed {
padding-top: 0 !important;
padding-bottom: 0 !important;
padding-left: 12px !important;
padding-right: 12px !important;
}
.navmini-page .brand-row {
@ -34,6 +37,12 @@
align-items: center;
}
.navmini-page .nav-status-spacer {
display: block;
width: 100%;
flex-shrink: 0;
}
.icon-btn svg,
.menu-icon,
.nav-portal-mark {

View File

@ -217,6 +217,79 @@ function NavPageInner() {
}
}, [])
const statusPad = Math.max(safe.statusBarHeight, 44)
const navPad = Math.max(safe.navBarHeight, 44)
const headerPad = statusPad + navPad
const topbar = (
<H5Box
className={`topbar sticky-stack${!isH5 ? ' topbar--tt-fixed' : ''}`}
style={
!isH5
? {
paddingTop: 0,
paddingBottom: 0,
paddingLeft: 12,
paddingRight: 12,
position: 'fixed',
top: 0,
left: 0,
right: 0,
zIndex: 100,
boxSizing: 'border-box',
background: 'rgba(10, 14, 23, 0.94)',
}
: undefined
}
>
{!isH5 ? (
<H5Box
className="nav-status-spacer"
style={{ height: `${statusPad}px`, width: '100%', flexShrink: 0 }}
/>
) : null}
<H5Box
className="brand-row"
style={
!isH5
? {
height: `${navPad}px`,
paddingRight: Math.max(safe.menuRightPad - 16, 88),
boxSizing: 'border-box',
alignItems: 'center',
}
: undefined
}
>
<H5Box
className={`icon-btn menu-trigger${drawerOpen ? ' open' : ''}`}
onClick={() => setDrawerOpen(true)}
>
{isH5 ? (
<H5Box html={MENU_SVG(drawerOpen)} />
) : (
<H5Txt>{drawerOpen ? '✕' : '☰'}</H5Txt>
)}
</H5Box>
<H5Box className="nav-portal-logo" onClick={goHome}>
{isH5 ? (
<H5Box html={LOGO_SVG} />
) : (
<Image className="hub-logo-img" src="/icons/nomadro.webp" mode="aspectFit" />
)}
<H5Txt className="nav-portal-brand">nomadro</H5Txt>
<H5Txt className="nav-portal-sep">·</H5Txt>
<H5Txt className="nav-portal-section">导航</H5Txt>
</H5Box>
<H5Txt key={`pc-${pillKey}`} className="pc-section-label">
{activeCategory.title}
</H5Txt>
</H5Box>
</H5Box>
)
const body = (
<H5Box className={`app-shell${drawerOpen ? ' drawer-open' : ''}`}>
<H5Box className="bg-glow" aria-hidden>
@ -253,68 +326,13 @@ function NavPageInner() {
</H5Box>
<H5Box className="desktop-main">
{/* H5 仍用 sticky;抖音顶栏提到 ScrollView 外 fixed */}
{isH5 ? topbar : null}
<H5Box
className="topbar sticky-stack"
style={
!isH5
? {
paddingTop: 0,
paddingBottom: 0,
paddingLeft: 12,
paddingRight: 12,
}
: undefined
}
className="page"
style={!isH5 ? { paddingTop: `${headerPad + 8}px` } : undefined}
>
{/* 独立占位:比 paddingTop 更稳,避免抖音 box-sizing 把内容压进状态栏 */}
{!isH5 ? (
<H5Box
className="nav-status-spacer"
style={{ height: Math.max(safe.statusBarHeight, 44), width: '100%' }}
/>
) : null}
<H5Box
className="brand-row"
style={
!isH5
? {
height: Math.max(safe.navBarHeight, 44),
paddingRight: Math.max(safe.menuRightPad - 16, 88),
boxSizing: 'border-box',
alignItems: 'center',
}
: undefined
}
>
<H5Box
className={`icon-btn menu-trigger${drawerOpen ? ' open' : ''}`}
onClick={() => setDrawerOpen(true)}
>
{isH5 ? (
<H5Box html={MENU_SVG(drawerOpen)} />
) : (
<H5Txt>{drawerOpen ? '✕' : '☰'}</H5Txt>
)}
</H5Box>
<H5Box className="nav-portal-logo" onClick={goHome}>
{isH5 ? (
<H5Box html={LOGO_SVG} />
) : (
<Image className="hub-logo-img" src="/icons/nomadro.webp" mode="aspectFit" />
)}
<H5Txt className="nav-portal-brand">nomadro</H5Txt>
<H5Txt className="nav-portal-sep">·</H5Txt>
<H5Txt className="nav-portal-section">导航</H5Txt>
</H5Box>
<H5Txt key={`pc-${pillKey}`} className="pc-section-label">
{activeCategory.title}
</H5Txt>
</H5Box>
</H5Box>
<H5Box className="page">
{visibleCategories.map((cat) => {
const count = countLinks(cat)
let flatIndex = 0
@ -420,10 +438,11 @@ function NavPageInner() {
</H5Box>
)
// 小程序:外层 ScrollView;弹层必须在 ScrollView 外,否则 fixed 点击失效
// 小程序:顶栏 fixed 在 ScrollView 外(sticky 在抖音 ScrollView 内会压进状态栏)
if (!isH5) {
return (
<H5Box className="navmini-page" data-theme={theme} style={safeStyle}>
{topbar}
<ScrollView
scrollY
className="navmini-root"