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


TypeScript app.on函數代碼示例

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


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

示例1: Start

	/**
	 * start the application itself.
	 */
	public Start(): void {

		this.mainWindow = null;

		// quit when all windows are closed.
		app.on("window-all-closed", () => this.WindowAllClose() );

		// this method will be called when Electron has done everything
		// initialization and ready for creating browser windows.
		app.on("ready", () => this.Ready() );
	}
開發者ID:fforjan,項目名稱:SimpleUML,代碼行數:14,代碼來源:application.ts

示例2: startIsolatedApp

function startIsolatedApp() {
    app.on('ready', () => {
        let win = new BrowserWindow({
            width: app_config.width,
            height: app_config.height,
        });

        win.loadUrl(index_html);

        let fetcher = new TrendFetcher(
                win.webContents,
                app_config.languages,
                app_config.proxy || undefined
            );
        auth.getToken().then((access_token: string) => {
            fetcher.setToken(access_token);
        });

        let app_icon = new Tray(normal_icon);
        const context_menu = Menu.buildFromTemplate([
            {
                label: 'Show Window',
                click: () => win.show(),
            },
            {
                label: 'Force Update',
                click: () => fetcher.doScraping(),
            },
            {
                label: 'Quit',
                accelerator: 'CmdOrCtrl+Q',
                click: () => app.quit(),
            }
        ]);
        app_icon.setContextMenu(context_menu);

        ipc.on('renderer-ready', () => fetcher.start());
        ipc.on('force-update-repos', () => fetcher.doScraping());
        ipc.on('tray-icon-normal', () => app_icon.setImage(normal_icon));
        ipc.on('tray-icon-notified', () => app_icon.setImage(notified_icon));
        ipc.on('start-github-login', () => doLogin(fetcher, win.webContents));

        if (app_config.hot_key !== '') {
            shortcut.register(
                    app_config.hot_key,
                    () => win.isVisible() ? win.hide() : win.show()
                );
        }
    });
}
開發者ID:kdallafior,項目名稱:Trendy,代碼行數:50,代碼來源:main.ts

示例3: require

const app = require('app');
const BrowserWindow = require('browser-window');
const IPC = require('electron').ipcMain;
let menu = require('./Menu');

let browserWindow: any = null;

app.on('open-file', (event: Event, file: string) => getMainWindow().webContents.send('change-working-directory', file))
    .on('ready', getMainWindow)
    .on('activate-with-no-open-windows', getMainWindow)
    .on('mainWindow-all-closed', () => process.platform === 'darwin' || app.quit());

IPC.on('quit', app.quit);

function getMainWindow() {
    const workAreaSize = require('screen').getPrimaryDisplay().workAreaSize;

    if (!browserWindow) {
        browserWindow = new BrowserWindow({
            'web-preferences': {
                'experimental-features': true,
                'experimental-canvas-features': true,
                'subpixel-font-scaling': true,
                'overlay-scrollbars': true
            },
            resizable: true,
            'min-width': 500,
            'min-height': 300,
            width: workAreaSize.width,
            height: workAreaSize.height,
            show: false
開發者ID:digideskio,項目名稱:black-screen,代碼行數:31,代碼來源:Main.ts

示例4: require

const app: Electron.App = require("app");
const browserWindowConstructor: typeof Electron.BrowserWindow = require("browser-window");
import {ipcMain, nativeImage} from "electron";
import menu from "./Menu";
let fixPath = require("fix-path");

let browserWindow: Electron.BrowserWindow = undefined;

// Fix the $PATH on OS X
fixPath();

if (app.dock) {
    app.dock.setIcon(nativeImage.createFromPath("icon.png"));
}

app.on("open-file", (event: Event, file: string) => getMainWindow().webContents.send("change-working-directory", file))
    .on("ready", getMainWindow)
    .on("activate", getMainWindow)
    .on("mainWindow-all-closed", () => process.platform === "darwin" || app.quit());

ipcMain.on("quit", app.quit);

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

    if (!browserWindow) {
        let options: Electron.BrowserWindowOptions = {
            webPreferences: {
                experimentalFeatures: true,
                experimentalCanvasFeatures: true,
開發者ID:Eugene-msc,項目名稱:black-screen,代碼行數:31,代碼來源:Main.ts

示例5: require

/// <reference path="../typings/node/node.d.ts" />
/// <reference path="../typings/github-electron/github-electron-main.d.ts" />

import E = GitHubElectron;
var app : E.App = require('app');
var BrowserWindow : typeof E.BrowserWindow = require('browser-window');

app.on('window-all-closed', () => {
  app.quit();
});

app.on('ready', () => {
  var mainWindow = new BrowserWindow({ width: 800, height: 600 });
  mainWindow.on('closed', () => { mainWindow = null; });
  mainWindow.openDevTools();
  mainWindow.loadUrl('file://' + __dirname + '/../index.html');
});
開發者ID:omo,項目名稱:hello2015,代碼行數:17,代碼來源:main.ts

示例6: require

/// <reference path="typings/browser/ambient/github-electron/electron-prebuilt/index.d.ts" />

'use sctrict';

const app = require('app');
const BrowserWindow = require('browser-window');
const mainWindow = null;

app.on('window-all-closed', function() {
  if (process.platform != 'darwin') {
    app.quit();
  }
});

app.on('ready', function() {
  mainWindow = new BrowserWindow({width: 800, height: 600});
  mainWindow.loadURL('file://' + __dirname + '/../html/index.html');
  mainWindow.on('closed', function() {
    mainWindow = null;
  });
})
開發者ID:KenjiOhtsuka,項目名稱:brief-spread,代碼行數:21,代碼來源:main.ts

示例7: require

import {AppConfigService} from './frameworks/app.framework/services/app-config.service';

crashReporter.start({
  productName: 'Angular2SeedAdvanced',
  companyName: 'NathanWalker',
  submitURL: 'https://github.com/NathanWalker/angular2-seed-advanced',
  autoSubmit: true
});

if (process.env.NODE_ENV === 'development') {
  require('electron-debug')();
}

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit();
  }
});

app.on('ready', () => {

  // Initialize the window to our specified dimensions
  mainWindow = new BrowserWindow({ width: 900, height: 620 });

  // Tell Electron where to load the entry point from
  mainWindow.loadURL('file://' + __dirname + '/index.html');

  // Clear out the main window when the app is closed
  mainWindow.on('closed', () => {
    mainWindow = null;
  });
開發者ID:TheLarkInn,項目名稱:angular2-seed-advanced,代碼行數:31,代碼來源:main.desktop.ts

示例8: require

import * as path from 'path';
import * as app from 'app';
import * as BrowserWindow from 'browser-window';
import setMenu from './menu';

const index_html = 'file://' + path.join(__dirname, '..', '..', 'index.html');

app.on('ready', () => {
    const display_size = require('screen').getPrimaryDisplay().workAreaSize;

    let win = new BrowserWindow({
        width: display_size.width,
        height: display_size.height,
        'title-bar-style': 'hidden-inset',
    });

    win.on('closed', () => {
        win = null;
        app.quit();
    });

    win.loadUrl(index_html);

    setMenu();
});
開發者ID:rexfordkelly-on-JS,項目名稱:Tilectron,代碼行數:25,代碼來源:main.ts

示例9: require

var Promise = require("promise");
import os = require("os");
import shellModule = require("./shellModel");
import userConfig = require("./user_configuration");
import utils = require('./utils');

// report crashes to the Electron project
require('crash-reporter').start();

// prevent window being GC'd
var mainWindow = null;
var shell = null;

app.on('window-all-closed', function () {
	if (process.platform !== 'darwin') {
		app.quit();
	}
});

ipc.on('platform', function(event, arg) {
  event.sender.send('platform', os.platform());
});

ipc.on('load-configuration', function(event, arg) {
  userConfig.loadConfiguration().then((config) => {
    event.sender.send('user-configuration', config);
  });
});

app.on('ready', function () {
	mainWindow = new BrowserWindow({
開發者ID:schultyy,項目名稱:jsterm,代碼行數:31,代碼來源:index.ts

示例10: require

declare var __dirname:string;

var fs = require('fs');
var app = require('app');  // Module to control application life.
var BrowserWindow = require('browser-window');  // Module to create native browser window.

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is GCed.
var mainWindow = null;

// Quit when all windows are closed.
app.on('window-all-closed', () => app.quit());

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', () => {
  // Create the browser window.
  mainWindow = new BrowserWindow({width: 800, height: 600});

  // and load the index.html of the app.
  var [_, _, testName] = process.argv;
  if (testName === "index") {
      mainWindow.loadUrl(`file://${__dirname}/index.html`);
  } else {
      var fs = require('fs');
      fs.readFile(__dirname + "/ui-test.template.html", 'utf8', (err,data) => {
          var result = data.replace("$$ENTER_HERE$$", testName);
          fs.writeFile(`${__dirname}/ui-test-${testName}.html`, result, 'utf8', (err) => {
              mainWindow.loadUrl(`file://${__dirname}/ui-test-${testName}.html`);
          });
      });
開發者ID:ludamad,項目名稱:boarders,代碼行數:31,代碼來源:ui-test-loader.ts


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