【问题标题】:ElectronJS Multiple MonitorsElectronJS 多显示器
【发布时间】:2019-01-19 09:07:19
【问题描述】:

我正在尝试创建一个应用程序,该应用程序在 2 个连接的监视器上以 Kiosk 模式打开 2 个不同的 BrowserWindows。我看到的有关如何执行此操作的唯一相关文档来自this page,这表明第二个显示器的边界应 > 0。不幸的是,当我记录每个显示器的 bounds 时,xy 属性在两个显示器上都是 0,尽管 size.widthsize.height 看起来准确。

对如何完成这个多屏信息亭有什么想法吗?

【问题讨论】:

  • “x 和 y 属性在两个显示器上都是 0”非常奇怪!你的操作系统是什么?

标签: electron


【解决方案1】:

根据documentation,您可以执行以下操作。

const electron = require('electron')
const {app, BrowserWindow} = require('electron')

let win

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')
  }
})

【讨论】:

  • 是的,我已经看到了,但正如我上面指出的,我没有看到任何带有 bounds.x 或 bounds.y !== 0 的显示。两个显示都有 bounds == 0 .
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-04-26
  • 1970-01-01
  • 2019-11-28
  • 2013-01-19
  • 1970-01-01
  • 1970-01-01
  • 2021-06-29
相关资源
最近更新 更多