From cd835b7c36967cc73b75145c4910d7c6610dad07 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Sat, 2 Nov 2024 15:13:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Ctrl=20+=20-=20=E7=BC=A9=E6=94=BE?= =?UTF-8?q?=E6=97=B6=20=E7=BC=A9=E5=88=B0=E6=9C=80=E5=B0=8F=20=E5=86=8D?= =?UTF-8?q?=E7=BC=A9=E7=9A=84=E8=AF=9D=E4=BC=9A=E6=8A=A5=E9=94=99=20#266?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/shortcut.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/shortcut.ts b/src/main/shortcut.ts index aa781935..1c8040b9 100644 --- a/src/main/shortcut.ts +++ b/src/main/shortcut.ts @@ -6,7 +6,11 @@ export function registerZoomShortcut(mainWindow: BrowserWindow) { globalShortcut.register('CommandOrControl+=', () => { if (mainWindow) { const currentZoom = mainWindow.webContents.getZoomFactor() - mainWindow.webContents.setZoomFactor(currentZoom + 0.1) + const newZoom = currentZoom + 0.1 + // Prevent zoom factor from exceeding reasonable limits + if (newZoom <= 5.0) { + mainWindow.webContents.setZoomFactor(newZoom) + } } }) @@ -14,7 +18,11 @@ export function registerZoomShortcut(mainWindow: BrowserWindow) { globalShortcut.register('CommandOrControl+-', () => { if (mainWindow) { const currentZoom = mainWindow.webContents.getZoomFactor() - mainWindow.webContents.setZoomFactor(currentZoom - 0.1) + const newZoom = currentZoom - 0.1 + // Prevent zoom factor from going below 0.1 + if (newZoom >= 0.1) { + mainWindow.webContents.setZoomFactor(newZoom) + } } })