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


TypeScript app.exit方法代碼示例

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


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

示例1: function

  let onReady = () => {
    if (!env.integrationTests) {
      const shouldQuit = app.makeSingleInstance((argv, cwd) => {
        // we only get inside this callback when another instance
        // is launched - so this executes in the context of the main instance
        store.dispatch(
          actions.processUrlArguments({
            args: argv,
          })
        );
        store.dispatch(actions.focusWind({ wind: "root" }));
      });
      if (shouldQuit) {
        app.exit(0);
        return;
      }
    }

    store.dispatch(
      actions.processUrlArguments({
        args: process.argv,
      })
    );

    globalShortcut.register("Control+Alt+Backspace", function() {
      store.dispatch(actions.forceCloseLastGame({}));
    });

    // Emitted when the application is activated. Various actions can trigger
    // this event, such as launching the application for the first time,
    // attempting to re-launch the application when it's already running, or
    // clicking on the application's dock or taskbar icon.
    app.on("activate", () => {
      store.dispatch(actions.focusWind({ wind: "root" }));
    });

    app.on("before-quit", e => {
      e.preventDefault();
      store.dispatch(actions.quit({}));
    });

    store.dispatch(actions.preboot({}));

    setInterval(() => {
      try {
        store.dispatch(actions.tick({}));
      } catch (e) {
        mainLogger.error(`While dispatching tick: ${e.stack}`);
      }
    }, 1 * 1000 /* every second */);
  };
開發者ID:itchio,項目名稱:itch,代碼行數:51,代碼來源:main.ts

示例2: function

  let onReady = () => {
    if (!env.integrationTests) {
      const shouldQuit = app.makeSingleInstance((argv, cwd) => {
        // we only get inside this callback when another instance
        // is launched - so this executes in the context of the main instance
        store.dispatch(
          actions.processUrlArguments({
            args: argv,
          })
        );
        store.dispatch(actions.focusWindow({ window: "root" }));
      });

      if (shouldQuit) {
        app.exit(0);
        return;
      }
    }

    store.dispatch(
      actions.processUrlArguments({
        args: process.argv,
      })
    );

    globalShortcut.register("Control+Alt+Backspace", function() {
      store.dispatch(actions.forceCloseLastGame({}));
    });

    if (rt) {
      rt.end();
    }

    store.dispatch(actions.preboot({}));

    setInterval(() => {
      try {
        store.dispatch(actions.tick({}));
      } catch (e) {
        logger.error(`While dispatching tick: ${e.stack}`);
      }
    }, 1 * 1000 /* every second */);
  };
開發者ID:HorrerGames,項目名稱:itch,代碼行數:43,代碼來源:metal.ts

示例3: createWindow

import loadConfig, {default_config} from './config';
import * as menu from './menu';
import WatchDog from './watcher';

// Show versions {{{
if (process.argv.indexOf('--version') !== -1) {
    const versions: any = process.versions;
    console.log(`Shiba v${app.getVersion()}

Environment:
  OS:       ${process.platform}-${process.arch}
  Electron: ${versions.electron}
  Chromium: ${versions.chrome}
  Node.js:  ${versions.node}
`);
    app.exit();
}
// }}}

// Main Window {{{
type DisplaySize = Electron.Size & {[k: string]: number};

function createWindow(config: Config, icon_path: string) {
    const display_size = screen.getPrimaryDisplay().workAreaSize as DisplaySize;

    function getConfigLength(key: 'width'|'height'): number {
        const len = config[key];
        const default_len = default_config[key] as number;
        switch (typeof len) {
            case 'string': {
                if (len === 'max') {
開發者ID:Sheshouzuo,項目名稱:Shiba,代碼行數:31,代碼來源:mainu.ts

示例4: function

 globals.FrontendDaemon.on('exit', function() {
   console.log('Frontend has exited.')
   elc.app.exit()
 })
開發者ID:nehbit,項目名稱:aether-public,代碼行數:4,代碼來源:mainmain.ts

示例5: setTimeout

 setTimeout(function() {
   elc.app.exit()
 }, 3000) // Hard limit - if it doesn't shut down in 3 seconds, we force kill it.
開發者ID:nehbit,項目名稱:aether-public,代碼行數:3,代碼來源:mainmain.ts

示例6: openAppWindow

      if (linkToLoadAtBoot.length > 0) {
        ipc.callRenderer(win, 'RouteTo', linkToLoadAtBoot)
      }
      openAppWindow()
    }
    if (win) {
      if (win.isMinimized()) {
        win.restore()
      }
      win.focus()
    }
  }
)

if (shouldQuitDueToAnotherInstanceBeingOpen) {
  elc.app.exit()
}

function EstablishExternalResourceAutoLoadFiltering() {
  // This is the list of allowed URLs that can be auto-loaded in electron. (This does not prevent links that open in your browser, just ones that fetch data within the app. You can link anywhere, but only links from the whitelist below will have a chance to auto-load.)

  /*
    Why does this list even exist? Shouldn't people be able to link to everywhere?

    You *can* link to everywhere, this list is just for auto-loading previews. Why does this matter? Because when an asset is auto-loaded, the entity on the other end (i.e. the sites below) will see your IP address as a normal user. That means, if there was no whitelist and all links were allowed to auto-load, then anybody could link to a site they control, and by listening to hits from IP addresses, it could figure out which IP addresses are using Aether. It wouldn't be able to figure out who is who, but the fact that IP is using Aether would be revealed.

    If you'd like to make things a little tighter in exchange to not being able to preview, replace this list with an empty one, and all auto-loads will be blocked.
  */

  let autoloadEnabledWhitelist = [
    'https://*.getaether.net/**',
開發者ID:nehbit,項目名稱:aether-public,代碼行數:31,代碼來源:mainmain.ts

示例7: require

let mainWindow: Electron.BrowserWindow;
let trayIcon: Electron.Tray;
let trayMenu: Electron.Menu;


/* tslint:disable */
const expectedElectronVersion = require(`${__dirname}/package.json`).superpowers.electron;
/* tslint:enable */
const electronVersion = (process.versions as any).electron as string;

if (electronVersion !== expectedElectronVersion) {
  console.log(`WARNING: Running Electron v${electronVersion}, but expected v${expectedElectronVersion}.`);
}

if (electron.app.makeSingleInstance(restoreMainWindow)) { electron.app.exit(0); }

electron.app.on("ready", onAppReady);
electron.app.on("activate", () => { restoreMainWindow(); });

let isQuitting = false;
let isReadyToQuit = false;
electron.app.on("before-quit", (event) => {
  if (!isQuitting) {
    event.preventDefault();
    startCleanExit();
    return;
  }

  if (!isReadyToQuit) event.preventDefault();
});
開發者ID:nitpum,項目名稱:superpowers-app,代碼行數:30,代碼來源:main.ts

示例8: async

 watcher.on(actions.quit, async (store, action) => {
   app.exit(0);
 });
開發者ID:HorrerGames,項目名稱:itch,代碼行數:3,代碼來源:main-window.ts

示例9:

const quit = () => {
  settings.persistToFile();
  app.exit();
};
開發者ID:wireapp,項目名稱:wire-desktop,代碼行數:4,代碼來源:lifecycle.ts

示例10: click

          shell.openExternal(
            'https://github.com/timche/gmail-desktop/issues/new/choose'
          )
        }
      }
    ]
  }
]

// Add the develop menu when running in the development environment
if (is.development) {
  darwinMenu.splice(-1, 0, {
    label: 'Develop',
    submenu: [
      {
        label: 'Clear Cache and Restart',
        click() {
          // Clear app config
          appConfig.deleteAll()
          // Restart without firing quitting events
          app.relaunch()
          app.exit(0)
        }
      }
    ]
  })
}

const menu = Menu.buildFromTemplate(darwinMenu)
export default menu
開發者ID:,項目名稱:,代碼行數:30,代碼來源:


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