优化竖屏为手机尺寸并放宽窗口最小尺寸限制

This commit is contained in:
JSR
2026-03-20 20:26:24 +08:00
parent 3cb15a9267
commit a7d5c59207
2 changed files with 14 additions and 12 deletions
+2 -2
View File
@@ -22,8 +22,8 @@
"decorations": false,
"transparent": false,
"center": true,
"minWidth": 800,
"minHeight": 600
"minWidth": 360,
"minHeight": 640
}
],
"security": {
+12 -10
View File
@@ -284,24 +284,26 @@ function MainContent(): React.JSX.Element {
const availableWidth = window.screen?.availWidth || window.innerWidth || 1200
const availableHeight = window.screen?.availHeight || window.innerHeight || 800
return {
maxWidth: Math.max(800, Math.round(availableWidth - 64)),
maxHeight: Math.max(600, Math.round(availableHeight - 64)),
maxWidth: Math.max(360, Math.round(availableWidth - 64)),
maxHeight: Math.max(640, Math.round(availableHeight - 64)),
}
}
const getFixedPortraitSize = () => {
const { maxWidth, maxHeight } = getMaxWindowSize()
const width = Math.min(940, maxWidth)
const height = Math.max(600, Math.min(1600, maxHeight))
const phonePortraitBase = { width: 430, height: 932 }
let width = Math.max(360, Math.min(phonePortraitBase.width, maxWidth))
let height = Math.max(640, Math.min(phonePortraitBase.height, maxHeight))
if (height > width) {
return { width, height }
// 保证竖屏高于宽,维持手机风格比例。
if (height <= width) {
height = Math.min(maxHeight, Math.max(640, Math.round(width * 2.0)))
}
if (height <= width) {
width = Math.max(360, Math.min(maxWidth, Math.round(height * 0.5)))
}
return {
width: Math.min(maxWidth, Math.max(800, width - 120)),
height: Math.min(maxHeight, Math.max(600, height + 120)),
}
return { width, height }
}
const getLandscapeRestoreSize = () => {