const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
var mainWindow;
app.on('ready', function() {
var electronScreen = electron.screen;
var size = electronScreen.getPrimaryDisplay().workAreaSize;
mainWindow = new BrowserWindow({ width: size.width, height: size.height });
});
const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
var mainWindow;
app.on('ready', function() {
var electronScreen = electron.screen;
var displays = electronScreen.getAllDisplays();
var externalDisplay = null;
for (var i in displays) {
if (displays[i].bounds.x != 0 || displays[i].bounds.y != 0) {
externalDisplay = displays[i];
break;
}
}
if (externalDisplay) {
mainWindow = new BrowserWindow({
x: externalDisplay.bounds.x + 50,
y: externalDisplay.bounds.y + 50
});
}
});
Display
对象
display
objectid
Integer - 与display 相关的唯一性标志.rotation
Integer - 可以是 0, 1, 2, 3, 每个代表了屏幕旋转的度数 0, 90, 180, 270.scaleFactor
Number - Output device's pixel scale factor.touchSupport
String - 可以是 available
, unavailable
, unknown
.bounds
Objectsize
ObjectworkArea
ObjectworkAreaSize
Object
事件
Event: 'display-added'
返回:
event
EventnewDisplay
Object
Event: 'display-removed'
返回:
event
EventoldDisplay
Object
Event: 'display-metrics-changed'
返回:
event
Eventdisplay
ObjectchangedMetrics
Array
方法
screen.getCursorScreenPoint()
screen.getPrimaryDisplay()
screen.getAllDisplays()
screen.getDisplayNearestPoint(point)
screen.getDisplayMatching(rect)
rect
Objectx
Integery
Integerwidth
Integerheight
Integer
请发表评论