电子外部显示边界



in the electron Doc (https://electronjs.org/docs/api/screen(

他们为什么要添加 x: externalDisplay.bounds.x + 50, y: externalDisplay.bounds.y + 50

窗口xy的+50 ?

app.on('ready', () => {
let displays = electron.screen.getAllDisplays()
let externalDisplay = displays.find((display) => {
return display.bounds.x !== 0 || display.bounds.y !== 0
})
if (externalDisplay) {
win = new BrowserWindow({
x: externalDisplay.bounds.x + 50,
y: externalDisplay.bounds.y + 50
})
win.loadURL('https://github.com')
}
})

也许你可以测试这段代码来找到这个要求的解决方案:

var scr = screen.getDisplayMatching(trayBounds)
console.warn("getDisplayMatching-x-y",scr.bounds);

最新更新