From e4c27530a663783084cfad6f0119d0474de0b61d Mon Sep 17 00:00:00 2001 From: Linkon <116425752+Linkon-lcw@users.noreply.github.com> Date: Tue, 20 Jan 2026 00:07:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BE=A7=E8=BE=B9=E6=A0=8F?= =?UTF-8?q?=E5=9C=A8=E7=BC=A9=E6=94=BE=E6=97=B6=E4=BD=8D=E7=BD=AE=E5=92=8C?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E9=94=99=E4=BD=8D=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=88=E6=B7=BB=E5=8A=A0=E7=AA=97=E5=8F=A3=E5=A4=A7=E5=B0=8F?= =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/services/SettingsService.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/services/SettingsService.ts b/src/main/services/SettingsService.ts index 4a90c8a..06e20d3 100644 --- a/src/main/services/SettingsService.ts +++ b/src/main/services/SettingsService.ts @@ -1,6 +1,6 @@ import { Service } from '../../shared/kernel' import { MainContext } from '../context' -import { BrowserWindow, webContents } from 'electron' +import { BrowserWindow, webContents, screen } from 'electron' import type { IpcMainInvokeEvent } from 'electron' import type { settingsKey, settingsSpec, settingChange } from '../../preload/types' import type { permissionLevel } from './PermissionService' @@ -53,14 +53,13 @@ export class SettingsService extends Service { kind: 'number', defaultValue: 1.0, writePermission: 'admin', - onChanged: (ctx, next) => { + onChanged: (_ctx, next) => { const zoom = Number(next) || 1.0 webContents.getAllWebContents().forEach((wc: any) => { wc.setZoomFactor(zoom) }) - // 更新全局侧边栏窗口的位置,确保在缩放后位置正确 - const { BrowserWindow, screen } = require('electron') + // 更新全局侧边栏窗口的位置和大小 const sidebarWindow = BrowserWindow.getAllWindows().find((win) => { try { return win.webContents.getURL().includes('#global-sidebar') @@ -72,8 +71,10 @@ export class SettingsService extends Service { if (sidebarWindow && !sidebarWindow.isDestroyed()) { const primaryDisplay = screen.getPrimaryDisplay() const { width, height } = primaryDisplay.workAreaSize - const winWidth = 84 - const winHeight = 300 + const baseWidth = 84 + const baseHeight = 300 + const winWidth = Math.round(baseWidth * zoom) + const winHeight = Math.round(baseHeight * zoom) sidebarWindow.setBounds({ x: width - winWidth,