本文整理汇总了TypeScript中electron.screen.getAllDisplays方法的典型用法代码示例。如果您正苦于以下问题:TypeScript screen.getAllDisplays方法的具体用法?TypeScript screen.getAllDisplays怎么用?TypeScript screen.getAllDisplays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron.screen
的用法示例。
在下文中一共展示了screen.getAllDisplays方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: enableHiresResources
function enableHiresResources(): void {
const scaleFactor = Math.max(
...electronScreen.getAllDisplays().map(display => display.scaleFactor)
);
if (scaleFactor === 1) {
return;
}
const filter = {urls: [`*://*.${domain}/`]};
session.defaultSession!.webRequest.onBeforeSendHeaders(
filter,
(details: OnSendHeadersDetails, callback: (response: BeforeSendHeadersResponse) => void) => {
let cookie = (details.requestHeaders as any).Cookie;
if (cookie && details.method === 'GET') {
if (/(; )?dpr=\d/.test(cookie)) {
cookie = cookie.replace(/dpr=\d/, `dpr=${scaleFactor}`);
} else {
cookie = `${cookie}; dpr=${scaleFactor}`;
}
(details.requestHeaders as any).Cookie = cookie;
}
callback({
cancel: false,
requestHeaders: details.requestHeaders
});
}
);
}
示例2: function
app.on('ready', function() {
// Create the browser window.
let displays = electron.screen.getAllDisplays()
let d = displays.find((display) => {
return { width: display.bounds.width, height: display.bounds.height }
})
let minScreenWidth = 650;
let minScreenHeight = 450;
mainWindow = new BrowserWindow({
width: Math.max(minScreenWidth, ~~(d.bounds.width * 0.75)),
height: Math.max(minScreenHeight, ~~(d.bounds.height * 0.75)),
minWidth: minScreenWidth,
minHeight: minScreenHeight,
title: 'Leto'
})
mainWindow.loadURL(`file://${ path.join(__dirname, '../www/index_electron.html')}`)
// Open the DevTools.
mainWindow.webContents.openDevTools({mode:'undocked'});
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
});
示例3: function
var ensureVisibleOnSomeDisplay = function(windowState) {
var visible = screen.getAllDisplays().some(function(display) {
return windowWithinBounds(windowState, display.bounds);
});
if (!visible) {
// Window is partially or fully not visible now.
// Reset it to safe defaults.
return resetToDefaults(windowState);
}
return windowState;
};
示例4: BrowserWindow
app.on('ready', () => {
var displays = screen.getAllDisplays();
var externalDisplay: any = 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,
});
}
});
示例5: BrowserWindow
app.on('ready', () => {
const displays = screen.getAllDisplays()
let externalDisplay: any = null
for (const 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
})
}
})
示例6: getSettings
mainWindow.on('restore', () => {
if (windowIsOffScreen(mainWindow.getBounds())) {
const bounds = mainWindow.getBounds();
let display = Electron.screen.getAllDisplays().find(display => display.id === getSettings().windowState.displayId);
display = display || Electron.screen.getDisplayMatching(bounds);
mainWindow.setPosition(display.workArea.x, display.workArea.y);
dispatch<WindowStateAction>({
type: 'Window_RememberBounds',
state: {
displayId: display.id,
width: bounds.width,
height: bounds.height,
left: display.workArea.x,
top: display.workArea.y
}
});
}
});
示例7:
socket.on('screen-getAllDisplays', () => {
var display = screen.getAllDisplays();
socket.emit('screen-getAllDisplaysCompleted', display);
});