From 605be2e480d3328dd3a576081c9ada03d0968a1f Mon Sep 17 00:00:00 2001 From: jackyu66git Date: Tue, 25 Aug 2026 01:22:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20WebView=20=E9=A1=B6=E6=A0=8F=E6=8C=89?= =?UTF-8?q?=E8=83=B6=E5=9B=8A=E6=8C=89=E9=92=AE=E8=AE=A1=E7=AE=97=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E5=8C=BA=E5=B9=B6=E7=BB=9F=E4=B8=80=E6=9A=96=E8=89=B2?= =?UTF-8?q?=E8=83=8C=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 传入 menuButton.bottom 作为 sbh,page 与 globalStyle 设置 backgroundColorTop 避免刘海黑条。 Co-authored-by: Cursor --- pages.json | 12 ++++++++++-- pages/yxg-magic/index.vue | 29 +++++++++++++++++++++++++---- util/yxgConfig.js | 2 +- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/pages.json b/pages.json index 8e06e39..084236e 100644 --- a/pages.json +++ b/pages.json @@ -11,8 +11,13 @@ "style": { "navigationBarTitleText": "", "navigationStyle": "custom", + "navigationBarTextStyle": "black", "backgroundColor": "#ffd1c7", - "backgroundColorTop": "#ffd1c7" + "backgroundColorTop": "#ffd1c7", + "mp-weixin": { + "navigationStyle": "custom", + "backgroundColorTop": "#ffd1c7" + } } }, { @@ -176,7 +181,10 @@ // "navigationBarTitleText": "uni-app", // "navigationBarBackgroundColor": "#F8F8F8", // "backgroundColor": "#F8F8F8", - "navigationStyle": "custom" + "navigationStyle": "custom", + "navigationBarTextStyle": "black", + "backgroundColor": "#ffd1c7", + "backgroundColorTop": "#ffd1c7" }, "uniIdRouter": {}, diff --git a/pages/yxg-magic/index.vue b/pages/yxg-magic/index.vue index a1dad16..108af73 100644 --- a/pages/yxg-magic/index.vue +++ b/pages/yxg-magic/index.vue @@ -6,16 +6,37 @@ import { computed } from 'vue' import { YXG_H5_BASE, YXG_H5_VERSION } from '@/util/yxgConfig.js' -const sys = uni.getSystemInfoSync() -const sbh = sys.statusBarHeight || 0 +/** H5 顶栏安全区:状态栏 + 胶囊行,避免 logo 与内容重叠 */ +function topInsetPx() { + const sys = uni.getSystemInfoSync() + const statusBar = sys.statusBarHeight || 0 + // #ifdef MP-WEIXIN + try { + const menu = uni.getMenuButtonBoundingClientRect() + if (menu && menu.bottom > statusBar) { + return Math.ceil(menu.bottom + 6) + } + } catch (_) {} + // #endif + return statusBar + 44 +} + +const topInset = topInsetPx() const h5Url = computed( - () => `${YXG_H5_BASE}?mp=1&v=${YXG_H5_VERSION}&sbh=${sbh}`, + () => `${YXG_H5_BASE}?mp=1&v=${YXG_H5_VERSION}&sbh=${topInset}`, ) + + diff --git a/util/yxgConfig.js b/util/yxgConfig.js index 24ae0fb..f18e6bd 100644 --- a/util/yxgConfig.js +++ b/util/yxgConfig.js @@ -1,4 +1,4 @@ /** 愈心魔方 H5(digital-psychology user-h5) */ -export const YXG_H5_VERSION = '202608252' +export const YXG_H5_VERSION = '202608253' export const YXG_H5_BASE = 'https://h5.yuxingu.com.cn/psy/' export const YXG_H5_HOME_URL = `${YXG_H5_BASE}?mp=1&v=${YXG_H5_VERSION}`