当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript screen.getAllDisplays方法代码示例

本文整理汇总了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
			});
		}
	);
}
开发者ID:kusamakura,项目名称:caprine,代码行数:33,代码来源:index.ts

示例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;
  });
});
开发者ID:HelixOne,项目名称:leto,代码行数:30,代码来源:electron.ts

示例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;
 };
开发者ID:chauey,项目名称:ngrev,代码行数:11,代码来源:window.ts

示例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,
		});
	}
});
开发者ID:longlho,项目名称:DefinitelyTyped,代码行数:17,代码来源:github-electron-renderer-tests.ts

示例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
    })
  }
})
开发者ID:doridoridoriand,项目名称:electron,代码行数:17,代码来源:renderer.ts

示例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
             }
         });
     }
 });
开发者ID:sarthakfx,项目名称:BotFramework-Emulator,代码行数:18,代码来源:main.ts

示例7:

 socket.on('screen-getAllDisplays', () => {
     var display = screen.getAllDisplays();
     socket.emit('screen-getAllDisplaysCompleted', display);
 });
开发者ID:E024,项目名称:Electron.NET,代码行数:4,代码来源:screen.ts


注:本文中的electron.screen.getAllDisplays方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。