當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。