display對象可以獲取所有顯示屏此處演示程式啟動是投放新視窗至另一屏幕 import { app, BrowserWindow } from 'electron' const electron = require('electron') //獲取electron對象 let newWindow ...
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)