This commit is contained in:
24kycj
2026-05-22 20:01:34 +08:00
parent d0c3fd162a
commit 79174e7e03
5 changed files with 15 additions and 18 deletions
+8 -8
View File
@@ -10,17 +10,13 @@ import { setupNativeWorkingDir } from './services/native-path'
suppressKnownDllStderr()
import { registerIpcHandlers, handleBeforeQuit } from './ipc/register-handlers'
import { setPollMainWindow } from './services/poll-manager'
import {
DESIGN_WIDTH,
contentHeightForWidth,
CONTENT_VIEWPORT_HEIGHT
} from '@shared/viewport'
import { DESIGN_WIDTH, DESIGN_HEIGHT, contentHeightForWidth } from '@shared/viewport'
let mainWindow: BrowserWindow | null = null
const MIN_CONTENT_WIDTH = 960
/** 默认内容区:约 85% 工作区宽,高按 720:390 */
/** 默认内容区:约 85% 工作区宽,高 = 宽×360/720 */
function getDefaultWindowSize(): { width: number; height: number } {
const { width: sw, height: sh } = screen.getPrimaryDisplay().workAreaSize
let w = Math.max(1280, Math.min(Math.floor(sw * 0.85), 1600))
@@ -28,7 +24,7 @@ function getDefaultWindowSize(): { width: number; height: number } {
const maxH = Math.floor(sh * 0.85)
if (h > maxH) {
h = Math.max(contentHeightForWidth(MIN_CONTENT_WIDTH), maxH)
w = Math.round((h * DESIGN_WIDTH) / CONTENT_VIEWPORT_HEIGHT)
w = Math.round((h * DESIGN_WIDTH) / DESIGN_HEIGHT)
}
return { width: w, height: h }
}
@@ -54,6 +50,10 @@ function createWindow(): void {
setPollMainWindow(mainWindow)
mainWindow.on('ready-to-show', () => {
if (mainWindow) {
const [cw] = mainWindow.getContentSize()
mainWindow.setContentSize(cw, contentHeightForWidth(cw))
}
mainWindow?.center()
mainWindow?.show()
if (!app.isPackaged) {
@@ -67,7 +67,7 @@ function createWindow(): void {
}
})
// 内容区 720:390画布仍 360 高,按宽缩放后底部可完整显示
// 内容区锁定 720:360与 useScale(scale = innerWidth/720) 一致
mainWindow.on('resize', () => {
if (!mainWindow) return
const [cw, ch] = mainWindow.getContentSize()