fix: Ctrl + - 缩放时 缩到最小 再缩的话会报错 #266
This commit is contained in:
parent
dd4239da87
commit
cd835b7c36
@ -6,7 +6,11 @@ export function registerZoomShortcut(mainWindow: BrowserWindow) {
|
|||||||
globalShortcut.register('CommandOrControl+=', () => {
|
globalShortcut.register('CommandOrControl+=', () => {
|
||||||
if (mainWindow) {
|
if (mainWindow) {
|
||||||
const currentZoom = mainWindow.webContents.getZoomFactor()
|
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+-', () => {
|
globalShortcut.register('CommandOrControl+-', () => {
|
||||||
if (mainWindow) {
|
if (mainWindow) {
|
||||||
const currentZoom = mainWindow.webContents.getZoomFactor()
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user