回退iOS视口实验并关闭透明窗口以修复黑边与白屏

This commit is contained in:
JSR
2026-03-19 20:13:01 +08:00
parent 07f9aee30b
commit 1dedb65956
2 changed files with 1 additions and 38 deletions
+1 -1
View File
@@ -20,7 +20,7 @@
"resizable": true, "resizable": true,
"fullscreen": false, "fullscreen": false,
"decorations": false, "decorations": false,
"transparent": true, "transparent": false,
"center": true, "center": true,
"minWidth": 800, "minWidth": 800,
"minHeight": 600 "minHeight": 600
-37
View File
@@ -77,43 +77,6 @@ const patchConsole = () => {
} }
patchConsole() patchConsole()
const syncAppViewportHeight = () => {
const rootStyle = document.documentElement.style
const readViewportHeight = () => {
const innerHeight = Number.isFinite(window.innerHeight) ? Math.round(window.innerHeight) : 0
const visualViewport = window.visualViewport
const visualHeight =
visualViewport && Number.isFinite(visualViewport.height) ? Math.round(visualViewport.height) : 0
return Math.max(innerHeight, visualHeight)
}
const applyHeight = () => {
try {
const viewportHeight = readViewportHeight()
// 避免 iOS 首帧偶发 0 高度把根节点压扁导致白屏
if (viewportHeight < 320) return
rootStyle.setProperty("--ss-app-height", `${viewportHeight}px`)
} catch {
void 0
}
}
applyHeight()
window.setTimeout(applyHeight, 50)
window.setTimeout(applyHeight, 300)
window.addEventListener("resize", applyHeight)
window.addEventListener("orientationchange", applyHeight)
const visualViewport = window.visualViewport
if (visualViewport && typeof visualViewport.addEventListener === "function") {
visualViewport.addEventListener("resize", applyHeight)
visualViewport.addEventListener("scroll", applyHeight)
}
}
syncAppViewportHeight()
const disableTouchZoom = () => { const disableTouchZoom = () => {
let lastTouchEnd = 0 let lastTouchEnd = 0