electron-vue多显示屏下将新窗口投放是其他屏幕

display对象可以获取所有显示屏
此处演示程序启动是投放新窗口至另一屏幕
import { app, BrowserWindow } from 'electron'
const electron = require('electron') //获取electron对象
let newWindow
function createWindow () {
  /**
   *主窗口省略
   */
  let displays = electron.screen.getAllDisplays()
  let externalDisplay = displays.find((display) => {
  return display.bounds.x !== 0 || display.bounds.y !== 0
  })
  if (externalDisplay) {
  newWindow = new BrowserWindow({
  fullscreen:false,
   x: externalDisplay.bounds.x + 500,
  y: externalDisplay.bounds.y + 50,
  width: 1000,
  height: 800
  })
  newWindow.loadURL(newURL)
  }
  newWindow.on('closed', () => {
  newWindow = null
  })
}
app.on('ready', createWindow)
posted @ 2019-07-05 10:22 胡子陵 阅读(...) 评论(...) 编辑 收藏