fix: WebView 顶栏按胶囊按钮计算安全区并统一暖色背景

传入 menuButton.bottom 作为 sbh,page 与 globalStyle 设置 backgroundColorTop 避免刘海黑条。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-25 01:22:40 +08:00
co-authored by Cursor
parent b74fd9caf5
commit 605be2e480
3 changed files with 36 additions and 7 deletions
+10 -2
View File
@@ -11,8 +11,13 @@
"style": { "style": {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"navigationStyle": "custom", "navigationStyle": "custom",
"navigationBarTextStyle": "black",
"backgroundColor": "#ffd1c7", "backgroundColor": "#ffd1c7",
"backgroundColorTop": "#ffd1c7" "backgroundColorTop": "#ffd1c7",
"mp-weixin": {
"navigationStyle": "custom",
"backgroundColorTop": "#ffd1c7"
}
} }
}, },
{ {
@@ -176,7 +181,10 @@
// "navigationBarTitleText": "uni-app", // "navigationBarTitleText": "uni-app",
// "navigationBarBackgroundColor": "#F8F8F8", // "navigationBarBackgroundColor": "#F8F8F8",
// "backgroundColor": "#F8F8F8", // "backgroundColor": "#F8F8F8",
"navigationStyle": "custom" "navigationStyle": "custom",
"navigationBarTextStyle": "black",
"backgroundColor": "#ffd1c7",
"backgroundColorTop": "#ffd1c7"
}, },
"uniIdRouter": {}, "uniIdRouter": {},
+25 -4
View File
@@ -6,16 +6,37 @@
import { computed } from 'vue' import { computed } from 'vue'
import { YXG_H5_BASE, YXG_H5_VERSION } from '@/util/yxgConfig.js' import { YXG_H5_BASE, YXG_H5_VERSION } from '@/util/yxgConfig.js'
const sys = uni.getSystemInfoSync() /** H5 顶栏安全区:状态栏 + 胶囊行,避免 logo 与内容重叠 */
const sbh = sys.statusBarHeight || 0 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( 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}`,
) )
</script> </script>
<style>
page {
background-color: #ffd1c7;
height: 100%;
}
</style>
<style scoped> <style scoped>
.yxg-webview { .yxg-webview {
width: 100%; width: 100%;
height: 100vh; height: 100%;
} }
</style> </style>
+1 -1
View File
@@ -1,4 +1,4 @@
/** 愈心魔方 H5digital-psychology user-h5 */ /** 愈心魔方 H5digital-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_BASE = 'https://h5.yuxingu.com.cn/psy/'
export const YXG_H5_HOME_URL = `${YXG_H5_BASE}?mp=1&v=${YXG_H5_VERSION}` export const YXG_H5_HOME_URL = `${YXG_H5_BASE}?mp=1&v=${YXG_H5_VERSION}`