feat(0.2.1): 合并 Windows 外壳 + 离线编辑, 版本 0.2.1, 正式域名 https://iboard.honor3.com

This commit is contained in:
jif2.zhang
2026-10-26 20:53:38 +08:00
parent e689e44923
commit eef296942f
74 changed files with 2734 additions and 437 deletions
+12 -2
View File
@@ -21,6 +21,16 @@ initOta()
function calibrateSafeTop() {
const root = document.documentElement
// 校准只对 Android 有意义 (状态栏/刘海让位)。桌面 (Windows WebView2 / 桌面浏览器)
// 没有状态栏: env() 本来就是 0; 而「screen.height - visualViewport.height」在桌面
// 竖屏窗口下会把标题栏+边框高度 (~99px) 误判成状态栏, 让标题栏下多出一条大空隙
// (2026-10-26 Windows 外壳实测)。非 Android 一律 0。
const isAndroid = /android/i.test(navigator.userAgent)
if (!isAndroid) {
root.style.setProperty('--safe-top', '0px')
return
}
// env() 的真实值必须用一个临时元素测量, 不能直接读 --safe-top ——
// 该变量是 max(env(...), 0px) 这样的表达式, parseFloat 会得到 NaN.
const probe = document.createElement('div')
@@ -37,7 +47,7 @@ function calibrateSafeTop() {
const viewH = window.visualViewport?.height || window.innerHeight || 0
const screenW = window.screen?.width || 0
const viewW = window.visualViewport?.width || window.innerWidth || 0
// 只在"纵向且高度差合理"时采用, 避免横屏/桌面窗口误判
// 只在"纵向且高度差合理"时采用, 避免横屏误判
const isPortrait = viewW <= viewH
const diff = screenH - viewH
const measured = isPortrait && diff > 0 && diff < 120 ? diff : 0
@@ -45,7 +55,7 @@ function calibrateSafeTop() {
// 取 env() 与实测值的较大者; 两者都失效时给 24px 保底
// (多数 Android 状态栏在 24~28px, 宁可多一点也不能压字)
let top = Math.max(envTop, measured)
if (top < 4) top = 24 // env 与实测都没拿到 → 用保守兜底, 保证不遮挡
if (top < 4) top = 24
root.style.setProperty('--safe-top', top + 'px')
}