fix: init zoom

This commit is contained in:
icinggslits 2025-02-18 02:43:22 +08:00 committed by 亢奋猫
parent aba3874797
commit bedac4f59d

View File

@ -47,8 +47,8 @@ function formatShortcutKey(shortcut: string[]): string {
function handleZoom(delta: number) { function handleZoom(delta: number) {
return (window: BrowserWindow) => { return (window: BrowserWindow) => {
const currentZoom = window.webContents.getZoomFactor() const currentZoom = configManager.getZoomFactor()
const newZoom = currentZoom + delta const newZoom = Number((currentZoom + delta).toFixed(1))
if (newZoom >= 0.1 && newZoom <= 5.0) { if (newZoom >= 0.1 && newZoom <= 5.0) {
window.webContents.setZoomFactor(newZoom) window.webContents.setZoomFactor(newZoom)
configManager.setZoomFactor(newZoom) configManager.setZoomFactor(newZoom)
@ -110,7 +110,9 @@ const convertShortcutRecordedByKeyboardEventKeyValueToElectronGlobalShortcutForm
} }
export function registerShortcuts(window: BrowserWindow) { export function registerShortcuts(window: BrowserWindow) {
window.webContents.setZoomFactor(configManager.getZoomFactor()) window.once('ready-to-show', () => {
window.webContents.setZoomFactor(configManager.getZoomFactor())
})
const register = () => { const register = () => {
if (window.isDestroyed()) return if (window.isDestroyed()) return