From 5a26841d3a0919f3340faa5ceaecf769d101ce21 Mon Sep 17 00:00:00 2001 From: jacy <18049821889@163.com> Date: Thu, 16 Jul 2026 08:05:44 +0800 Subject: [PATCH] fix(h5): hide in-page nav titles that duplicate WeChat chrome Keep back buttons and header layout. mini-user only hides titles on H5; partner/shop hide .app-page-title and legal titles; shared PageHeader defaults showTitle=false. --- apps/h5-partner/src/styles.css | 8 ++++++++ apps/h5-partner/src/styles/legal.css | 7 +++++-- apps/h5-shop/src/styles.css | 8 ++++++++ apps/h5-shop/src/styles/legal.css | 7 +++++-- apps/mini-user/src/components/PageNavBar.tsx | 8 ++++++-- .../mini-user/src/components/SubPageHeader.tsx | 6 ++++-- .../mini-user/src/components/TabMainHeader.tsx | 8 +++++--- apps/mini-user/src/pages/benefit/index.tsx | 6 ++++-- packages/shared-ui/src/PageHeader.tsx | 18 +++++++++++++++--- packages/shared-ui/src/base.css | 6 ++++++ 10 files changed, 66 insertions(+), 16 deletions(-) diff --git a/apps/h5-partner/src/styles.css b/apps/h5-partner/src/styles.css index 5d7ac46..63e6ddf 100644 --- a/apps/h5-partner/src/styles.css +++ b/apps/h5-partner/src/styles.css @@ -3065,3 +3065,11 @@ body { padding-top: 12px; border-top: 1px dashed rgba(166, 29, 36, 0.15); } + +/* 微信 H5 系统标题已展示:隐藏页内重复标题,保留返回键与顶栏布局 */ +.app-page-title { + visibility: hidden; + font-size: 0 !important; + line-height: 0 !important; + color: transparent !important; +} diff --git a/apps/h5-partner/src/styles/legal.css b/apps/h5-partner/src/styles/legal.css index 800aac1..e730c01 100644 --- a/apps/h5-partner/src/styles/legal.css +++ b/apps/h5-partner/src/styles/legal.css @@ -35,8 +35,11 @@ .legal-h5-title { margin: 0; - font-size: 17px; - font-weight: 600; + /* 与微信系统标题重复,仅保留顶栏高度与返回 */ + visibility: hidden; + font-size: 0; + line-height: 0; + color: transparent; } .legal-h5-body { diff --git a/apps/h5-shop/src/styles.css b/apps/h5-shop/src/styles.css index 25c4e19..205302a 100644 --- a/apps/h5-shop/src/styles.css +++ b/apps/h5-shop/src/styles.css @@ -2702,3 +2702,11 @@ cursor: pointer; } +/* 微信 H5 系统标题已展示:隐藏页内重复标题,保留返回键与顶栏布局 */ +.app-page-title { + visibility: hidden; + font-size: 0 !important; + line-height: 0 !important; + color: transparent !important; +} + diff --git a/apps/h5-shop/src/styles/legal.css b/apps/h5-shop/src/styles/legal.css index 800aac1..e730c01 100644 --- a/apps/h5-shop/src/styles/legal.css +++ b/apps/h5-shop/src/styles/legal.css @@ -35,8 +35,11 @@ .legal-h5-title { margin: 0; - font-size: 17px; - font-weight: 600; + /* 与微信系统标题重复,仅保留顶栏高度与返回 */ + visibility: hidden; + font-size: 0; + line-height: 0; + color: transparent; } .legal-h5-body { diff --git a/apps/mini-user/src/components/PageNavBar.tsx b/apps/mini-user/src/components/PageNavBar.tsx index 40397ff..7920d66 100644 --- a/apps/mini-user/src/components/PageNavBar.tsx +++ b/apps/mini-user/src/components/PageNavBar.tsx @@ -10,6 +10,8 @@ type PageNavBarProps = { right?: ReactNode; }; +const isH5 = process.env.TARO_ENV === 'h5'; + /** 内页自定义导航栏(返回 + 标题 + 右侧操作),适配刘海屏 */ export default function PageNavBar({ title, @@ -19,16 +21,18 @@ export default function PageNavBar({ right, }: PageNavBarProps) { const metrics = useNavBarMetrics(); + const showTitle = !isH5 && titleVisible; return ( - {title} + {showTitle ? title : ''} - {title} + + {!isH5 ? {title} : null} - {title} + + {!isH5 ? {title} : null} - - 好客权益 + + {process.env.TARO_ENV !== 'h5' ? ( + 好客权益 + ) : null} void; backLabel?: string; right?: React.ReactNode; + /** 是否展示居中标题;H5 微信内默认隐藏,避免与系统标题栏重复 */ + showTitle?: boolean; }; -export default function PageHeader({ title, onBack, backLabel = '←', right }: PageHeaderProps) { +export default function PageHeader({ + title, + onBack, + backLabel = '←', + right, + showTitle = false, +}: PageHeaderProps) { return ( -
+
{onBack ? (
-
{title}
+ {showTitle ? ( +
{title}
+ ) : ( +
); diff --git a/packages/shared-ui/src/base.css b/packages/shared-ui/src/base.css index 9b8618c..301b779 100644 --- a/packages/shared-ui/src/base.css +++ b/packages/shared-ui/src/base.css @@ -531,6 +531,12 @@ button, input, select, textarea { font: inherit; } flex: 1; } +.page-header-title--spacer { + font-size: 0; + line-height: 0; + min-height: 26px; +} + /* Coupon badge (ticket notch) */ .coupon-badge { position: relative;