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


TypeScript app.once方法代码示例

本文整理汇总了TypeScript中electron.app.once方法的典型用法代码示例。如果您正苦于以下问题:TypeScript app.once方法的具体用法?TypeScript app.once怎么用?TypeScript app.once使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在electron.app的用法示例。


在下文中一共展示了app.once方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: init

	export async function init() {
		log('Waiting for app to be ready');
		app.once('ready', async () => {
			log('App is ready, waiting for settings to initialize');
			await Settings.init();
			log('Settings initialized');
			await Setup.init();
			log('Done setupping, initializing autolauncher');
			await AutoLauncher.init();
			log('Initializing tray icon');
			SystemTray.init();
			log('Done initializing everything');

			if (Refs.DEBUG || !(await Settings.get('launchOnBoot'))) {
				//Not launch on boot, that means that this launch should start the app
				log('Launching main window');
				launch(true);
			} else {
				log('Not launching main window');
			}

			app.on('window-all-closed', async () => {
				if (Refs.DEBUG || !(await Settings.get('launchOnBoot'))) {
					//Not launch on boot, so close when done
					app.quit();
				}
			});
		});
	}
开发者ID:SanderRonde,项目名称:youtube-music-app,代码行数:29,代码来源:app.ts

示例2: makeDefaultConfig

 fs.readFile(file, 'utf8', (err, json) => {
     if (err) {
         log.info('Configuration file was not found, will create:', file);
         const onSaved = (saveErr: Error) => {
             if (saveErr) {
                 log.error('Failed to write configuration file:', file, saveErr);
             } else {
                 log.info('Configuration file was created at', file);
             }
         };
         const default_config = makeDefaultConfig();
         // Note:
         // If calling writeFile() directly here, it tries to create config file before Electron
         // runtime creates data directory. As the result, writeFile() would fail to create a file.
         if (app.isReady()) {
             fs.writeFile(file, JSON.stringify(default_config, null, 2), onSaved);
         } else {
             app.once('ready', () => fs.writeFile(file, JSON.stringify(default_config, null, 2), onSaved));
         }
         return resolve(default_config);
     }
     try {
         const config = JSON.parse(json);
         if (config.hot_key && config.hot_key.startsWith('mod+')) {
             config.hot_key = `CmdOrCtrl+${config.hot_key.slice(4)}`;
         }
         log.debug('Configuration was loaded successfully', config);
         resolve(config);
     } catch (e) {
         log.error('Error on loading JSON file, will load default configuration:', e.message);
         resolve(makeDefaultConfig());
     }
 });
开发者ID:rhysd,项目名称:Tui,代码行数:33,代码来源:config.ts

示例3: it

 it('should emit browser-window-blur event when window is blured', (done) => {
   app.once('browser-window-blur', (e, window) => {
     expect(w.id).to.equal(window.id)
     done()
   })
   w = new BrowserWindow({ show: false })
   w.emit('blur')
 })
开发者ID:malept,项目名称:electron,代码行数:8,代码来源:api-app-spec.ts

示例4: handlePotentialProtocolLaunch

const handlePotentialProtocolLaunch = (url: string) => {
  if (!app.isReady()) {
    app.once('ready', () => handlePotentialProtocolLaunch(url));
    return;
  }
  const parsed = nodeUrl.parse(url.replace(/\/$/, ''));
  if (!parsed.pathname) return;
  const pathParts = parsed.pathname.split('/');
  if (pathParts.length <= 0 || pathParts.length > 2) return;

  ipcMainManager.send(IpcEvents.LOAD_GIST_REQUEST, [parsed.pathname]);
};
开发者ID:cocoflan,项目名称:fiddle-electron,代码行数:12,代码来源:protocol.ts

示例5:

			this.pendingQuitPromise = new TPromise<boolean>((c) => {

				// Store as field to access it from a window cancellation
				this.pendingQuitPromiseComplete = c;

				app.once('will-quit', () => {
					if (this.pendingQuitPromiseComplete) {
						this.pendingQuitPromiseComplete(false /* no veto */);
						delete this.pendingQuitPromiseComplete;
						delete this.pendingQuitPromise;
					}
				});

				app.quit();
			});
开发者ID:carhero,项目名称:vscode,代码行数:15,代码来源:lifecycle.ts

示例6: start

export async function start(
  getMainWindow: () => BrowserWindow,
  messages: MessagesType,
  logger: LoggerType
) {
  logger.info('macos/start: starting checks...');

  loggerForQuitHandler = logger;
  app.once('quit', quitHandler);

  setInterval(async () => {
    try {
      await checkDownloadAndInstall(getMainWindow, messages, logger);
    } catch (error) {
      logger.error('macos/start: error:', getPrintableError(error));
    }
  }, INTERVAL);

  await checkDownloadAndInstall(getMainWindow, messages, logger);
}
开发者ID:WhisperSystems,项目名称:Signal-Desktop,代码行数:20,代码来源:macos.ts

示例7: function

        win.setMenuBarVisibility(false);
    }

    win.once('closed', function() {
        win = null;
    });

    win.loadURL(index_html);
    if (process.env.NODE_ENV !== 'production' && is_run_from_npm_package_on_darwin) {
        win.webContents.openDevTools({mode: 'detach'});
    }

    return win;
}

app.once('window-all-closed', () => app.quit());
app.on('open-url', (e: Event, u: string) => {
    e.preventDefault();
    shell.openExternal(u);
});

app.once(
    'ready',
    () => {
        if (process.platform === 'darwin' && is_run_from_npm_package_on_darwin) {
            // XXX:
            // app.dock.setIcon() is not defined in github-electron.d.ts yet.
            (app.dock as any).setIcon(join(__dirname, '..', 'resources', 'icon', 'nyaovim-logo.png'));
        }

        Promise.all([
开发者ID:haifengkao,项目名称:NyaoVim-Unofficial,代码行数:31,代码来源:main.ts


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