cherry-studio/src/main/utils/zoom.ts
one 4ac8a38834
style: set eol to lf, code formatting (#7923)
* chore(gitattributes): set eol to lf

* chore: git renormalize

* style: reformatting

* chore: keep eslint prettier plugin consistent on eol
2025-07-08 09:50:33 +08:00

27 lines
655 B
TypeScript

import { BrowserWindow } from 'electron'
import { configManager } from '../services/ConfigManager'
export function handleZoomFactor(wins: BrowserWindow[], delta: number, reset: boolean = false) {
if (reset) {
wins.forEach((win) => {
win.webContents.setZoomFactor(1)
})
configManager.setZoomFactor(1)
return
}
if (delta === 0) {
return
}
const currentZoom = configManager.getZoomFactor()
const newZoom = Number((currentZoom + delta).toFixed(1))
if (newZoom >= 0.5 && newZoom <= 2.0) {
wins.forEach((win) => {
win.webContents.setZoomFactor(newZoom)
})
configManager.setZoomFactor(newZoom)
}
}