From 788a2abbe406d4181b2f0064758599df0aca9c61 Mon Sep 17 00:00:00 2001 From: let5sne Date: Sun, 26 Jul 2026 00:58:18 +0800 Subject: [PATCH] fix(mobile): avoid status bar overlap on custom-nav pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 全局 navigationStyle 为 custom,页面需自行避让状态栏,但四处顶部内容仍被状态栏 压住:练习页标题与对话页标题、我的页顶部卡片、问答页头部。 避让不能走 CSS:env(safe-area-inset-top) 在 Android WebView 恒为 0(该值本是 iOS 刘海概念,Chromium 仅在配置 display-cutout 时才上报),uni-app 注入的 --status-bar-height 实测在 App 端同样取不到,两者都会静默回落成 0,造成"构建产物 里改动存在但运行时无效"。改由 utils/safe-area.ts 读 uni.getSystemInfoSync().statusBarHeight,各页面以内联样式绑定 padding-top。 profile 页同时把 min-height 从 100vh 改为 100%:叠加状态栏内边距后 100vh 会 溢出一屏高度产生多余滚动。 真机(vivo V2443A,720x1600,状态栏 72px)像素验证:修复前状态栏下缘 60-80px 带内 有 872 个文字像素,修复后四处均为 0。 Co-Authored-By: Claude Opus 5 (1M context) --- .gitignore | 1 + .../src/components/chat/AskSourceHeader.vue | 9 ++++-- mobile-uni/src/pages/user/practice/index.vue | 9 ++++-- mobile-uni/src/pages/user/profile/index.vue | 7 +++-- mobile-uni/src/styles/base.css | 4 +++ mobile-uni/src/utils/safe-area.ts | 28 +++++++++++++++++++ 6 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 mobile-uni/src/utils/safe-area.ts diff --git a/.gitignore b/.gitignore index dedfe6a5..05447e41 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ mobile-uni/certificates/ mobile-uni/androidPrivacy.json .tmp/ .worktrees/ +mobile-uni/.hbuilderx/ diff --git a/mobile-uni/src/components/chat/AskSourceHeader.vue b/mobile-uni/src/components/chat/AskSourceHeader.vue index 06fd10bb..8c3edf4e 100644 --- a/mobile-uni/src/components/chat/AskSourceHeader.vue +++ b/mobile-uni/src/components/chat/AskSourceHeader.vue @@ -1,5 +1,5 @@