當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript electron.screen類代碼示例

本文整理匯總了TypeScript中electron.screen的典型用法代碼示例。如果您正苦於以下問題:TypeScript screen類的具體用法?TypeScript screen怎麽用?TypeScript screen使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了screen類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: BrowserWindow

app.on('ready', () => {
    let cursorPos = screen.getCursorScreenPoint()
    let workAreaSize = screen.getDisplayNearestPoint(cursorPos).workAreaSize

    app.setName('Ansel')

    mainWindow = new BrowserWindow({
        width: 1356,
        height: 768,
        title: 'Ansel',
        titleBarStyle: 'hiddenInset',
        backgroundColor: '#37474f',  // @blue-grey-800
        webPreferences: {
            experimentalFeatures: true,
            blinkFeatures: 'CSSGridLayout'
        }
    })

    if (workAreaSize.width <= 1366 && workAreaSize.height <= 768)
        mainWindow.maximize()

    mainWindow.loadURL('file://' + __dirname + '/../../static/index.html')
    mainWindow.setTitle('Ansel')
    initBackgroundService(mainWindow)
    initForegroundClient(mainWindow)

    //let usb = new Usb()
    //
    //usb.scan((err, drives) => {
    //  mainWindow.webContents.send('scanned-devices', drives)
    //})
    //
    //usb.watch((err, action, drive) => {
    //  if (action === 'add')
    //    mainWindow.webContents.send('add-device', drive)
    //  else
    //    mainWindow.webContents.send('remove-device', drive)
    //})

    if (fs.existsSync(config.settings)) {
        initLibrary(mainWindow)
    } else {
        initDb()
        ipcMain.on('settings-created', () => initLibrary(mainWindow))
    }

    // Emitted when the window is closed.
    mainWindow.on('closed', () => {
        // 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:m0g,項目名稱:ansel,代碼行數:54,代碼來源:entry.ts

示例2: async

  watcher.on(actions.preferencesLoaded, async (store, action) => {
    const hidden = action.payload.openAsHidden;
    if (!hidden) {
      store.dispatch(actions.focusWindow({ window: "root" }));
    }

    screen.on("display-added", () => ensureMainWindowInsideDisplay(store));
    screen.on("display-removed", () => ensureMainWindowInsideDisplay(store));
    screen.on("display-metrics-changed", () =>
      ensureMainWindowInsideDisplay(store)
    );
  });
開發者ID:HorrerGames,項目名稱:itch,代碼行數:12,代碼來源:main-window.ts

示例3: createWindow

function createWindow() {

  const size = screen.getPrimaryDisplay().workAreaSize;

  // Create the browser window.
  win = new BrowserWindow({
    x: 0,
    y: 0,
    width: size.width,
    height: size.height
  });

  // and load the index.html of the app.
  win.loadURL(url.format({
    protocol: 'file:',
    pathname: path.join(__dirname, '/index.html'),
    slashes: true
  }));

  if (serve) {
    win.webContents.openDevTools();
  }
  // Emitted when the window is closed.
  win.on('closed', () => {
    // Dereference the window object, usually you would store window
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    win = null;
  });
}
開發者ID:meltedspark,項目名稱:electron-angular2-native,代碼行數:30,代碼來源:main.electron.ts

示例4: createWindow

    function createWindow() {
        const size = screen.getPrimaryDisplay().workAreaSize;
        const args = process.argv.slice(1);

        window = new BrowserWindow({
            backgroundColor: '#ffffff',
            icon: `${__dirname}/ux/favicon.ico`,
            width: size.width,
            height: size.height
        });
        
        if(args.some(val => val == '--serve')) {
            require('electron-reload')(__dirname, {
                electron: require(`${__dirname}/../node_modules/electron`)
            });
            window.loadURL(`http://localhost:4200/`);
        }
        else {
            window.loadURL(`file://${__dirname}/ux/index.html`);
        }
         
        window.on('closed', function() {
            window = null;
        });
    }
開發者ID:MikeCook9994,項目名稱:TwitchPlaysTinder,代碼行數:25,代碼來源:main.ts

示例5: 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

示例6: function

 var resetToDefaults = function(windowState) {
   var bounds = screen.getPrimaryDisplay().bounds;
   return Object.assign({}, defaultSize, {
     x: (bounds.width - defaultSize.width) / 2,
     y: (bounds.height - defaultSize.height) / 2
   });
 };
開發者ID:chauey,項目名稱:ngrev,代碼行數:7,代碼來源:window.ts

示例7: getMainWindow

function getMainWindow(): Electron.BrowserWindow {
    const workAreaSize = screen.getPrimaryDisplay().workAreaSize;

    if (!browserWindow) {
        let options: Electron.BrowserWindowOptions = {
            webPreferences: {
                experimentalFeatures: true,
                experimentalCanvasFeatures: true,
            },
            titleBarStyle: "hidden",
            resizable: true,
            minWidth: 500,
            minHeight: 300,
            width: workAreaSize.width,
            height: workAreaSize.height,
            show: false,
        };
        browserWindow = new BrowserWindow(options);

        browserWindow.loadURL("file://" + __dirname + "/../views/index.html");
        menu.setMenu(app, browserWindow);

        browserWindow.on("closed", (): void => browserWindow = undefined)
                     .on("focus", (): void => app.dock && app.dock.setBadge(""));

        browserWindow.webContents.on("did-finish-load", () => {
            browserWindow.show();
            browserWindow.focus();
        });
    }

    return browserWindow;
}
開發者ID:F2Ealexis,項目名稱:black-screen,代碼行數:33,代碼來源:Main.ts

示例8: function

var windowIsOffScreen = function(windowBounds: Electron.Rectangle): boolean {
    const nearestDisplay = Electron.screen.getDisplayMatching(windowBounds).workArea;
    return (
        windowBounds.x > (nearestDisplay.x + nearestDisplay.width) ||
        (windowBounds.x + windowBounds.width) < nearestDisplay.x ||
        windowBounds.y > (nearestDisplay.y + nearestDisplay.height) ||
        (windowBounds.y + windowBounds.height) < nearestDisplay.y
    );
}
開發者ID:sarthakfx,項目名稱:BotFramework-Emulator,代碼行數:9,代碼來源:main.ts

示例9: 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

示例10: 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


注:本文中的electron.screen類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。