mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-21 09:39:03 +08:00
修复侧边栏在缩放时位置错位的问题
This commit is contained in:
@@ -53,11 +53,35 @@ export class SettingsService extends Service {
|
|||||||
kind: 'number',
|
kind: 'number',
|
||||||
defaultValue: 1.0,
|
defaultValue: 1.0,
|
||||||
writePermission: 'admin',
|
writePermission: 'admin',
|
||||||
onChanged: (_ctx, next) => {
|
onChanged: (ctx, next) => {
|
||||||
const zoom = Number(next) || 1.0
|
const zoom = Number(next) || 1.0
|
||||||
webContents.getAllWebContents().forEach((wc: any) => {
|
webContents.getAllWebContents().forEach((wc: any) => {
|
||||||
wc.setZoomFactor(zoom)
|
wc.setZoomFactor(zoom)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 更新全局侧边栏窗口的位置,确保在缩放后位置正确
|
||||||
|
const { BrowserWindow, screen } = require('electron')
|
||||||
|
const sidebarWindow = BrowserWindow.getAllWindows().find((win) => {
|
||||||
|
try {
|
||||||
|
return win.webContents.getURL().includes('#global-sidebar')
|
||||||
|
} catch {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (sidebarWindow && !sidebarWindow.isDestroyed()) {
|
||||||
|
const primaryDisplay = screen.getPrimaryDisplay()
|
||||||
|
const { width, height } = primaryDisplay.workAreaSize
|
||||||
|
const winWidth = 84
|
||||||
|
const winHeight = 300
|
||||||
|
|
||||||
|
sidebarWindow.setBounds({
|
||||||
|
x: width - winWidth,
|
||||||
|
y: Math.floor(height / 2 - winHeight / 2),
|
||||||
|
width: winWidth,
|
||||||
|
height: winHeight
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user