From e5a6561fa74d47a8f716101cd650e04cf38dbe3a Mon Sep 17 00:00:00 2001 From: eric Date: Wed, 30 Sep 2026 15:21:52 +0800 Subject: [PATCH] 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 --- apps/miniprogram/tt/src/pages/nav/index.scss | 13 +- apps/miniprogram/tt/src/pages/nav/index.tsx | 141 +++++++++++-------- 2 files changed, 91 insertions(+), 63 deletions(-) diff --git a/apps/miniprogram/tt/src/pages/nav/index.scss b/apps/miniprogram/tt/src/pages/nav/index.scss index 6f53453..57f6f7f 100644 --- a/apps/miniprogram/tt/src/pages/nav/index.scss +++ b/apps/miniprogram/tt/src/pages/nav/index.scss @@ -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 { diff --git a/apps/miniprogram/tt/src/pages/nav/index.tsx b/apps/miniprogram/tt/src/pages/nav/index.tsx index d22d2be..b857940 100644 --- a/apps/miniprogram/tt/src/pages/nav/index.tsx +++ b/apps/miniprogram/tt/src/pages/nav/index.tsx @@ -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 = ( + + {!isH5 ? ( + + ) : null} + + setDrawerOpen(true)} + > + {isH5 ? ( + + ) : ( + {drawerOpen ? '✕' : '☰'} + )} + + + + {isH5 ? ( + + ) : ( + + )} + nomadro + · + 导航 + + + + {activeCategory.title} + + + + ) + const body = ( @@ -253,68 +326,13 @@ function NavPageInner() { + {/* H5 仍用 sticky;抖音顶栏提到 ScrollView 外 fixed */} + {isH5 ? topbar : null} + - {/* 独立占位:比 paddingTop 更稳,避免抖音 box-sizing 把内容压进状态栏 */} - {!isH5 ? ( - - ) : null} - - setDrawerOpen(true)} - > - {isH5 ? ( - - ) : ( - {drawerOpen ? '✕' : '☰'} - )} - - - - {isH5 ? ( - - ) : ( - - )} - nomadro - · - 导航 - - - - {activeCategory.title} - - - - - {visibleCategories.map((cat) => { const count = countLinks(cat) let flatIndex = 0 @@ -420,10 +438,11 @@ function NavPageInner() { ) - // 小程序:外层 ScrollView;弹层必须在 ScrollView 外,否则 fixed 点击失效 + // 小程序:顶栏 fixed 在 ScrollView 外(sticky 在抖音 ScrollView 内会压进状态栏) if (!isH5) { return ( + {topbar}