From bedac4f59d438eabf21e33d5bb84575376715f91 Mon Sep 17 00:00:00 2001 From: icinggslits Date: Tue, 18 Feb 2025 02:43:22 +0800 Subject: [PATCH] fix: init zoom --- src/main/services/ShortcutService.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/services/ShortcutService.ts b/src/main/services/ShortcutService.ts index 5f03ac51..d9920981 100644 --- a/src/main/services/ShortcutService.ts +++ b/src/main/services/ShortcutService.ts @@ -47,8 +47,8 @@ function formatShortcutKey(shortcut: string[]): string { function handleZoom(delta: number) { return (window: BrowserWindow) => { - const currentZoom = window.webContents.getZoomFactor() - const newZoom = currentZoom + delta + const currentZoom = configManager.getZoomFactor() + const newZoom = Number((currentZoom + delta).toFixed(1)) if (newZoom >= 0.1 && newZoom <= 5.0) { window.webContents.setZoomFactor(newZoom) configManager.setZoomFactor(newZoom) @@ -110,7 +110,9 @@ const convertShortcutRecordedByKeyboardEventKeyValueToElectronGlobalShortcutForm } export function registerShortcuts(window: BrowserWindow) { - window.webContents.setZoomFactor(configManager.getZoomFactor()) + window.once('ready-to-show', () => { + window.webContents.setZoomFactor(configManager.getZoomFactor()) + }) const register = () => { if (window.isDestroyed()) return