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)

转载于:https://www.cnblogs.com/zhj-hu/p/11136734.html

Logo

前往低代码交流专区

更多推荐