本文整理汇总了TypeScript中electron.app.quit方法的典型用法代码示例。如果您正苦于以下问题:TypeScript app.quit方法的具体用法?TypeScript app.quit怎么用?TypeScript app.quit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron.app
的用法示例。
在下文中一共展示了app.quit方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});
示例2:
mainWindow.on('close', (e) => {
if (forceQuit) {
app.quit();
} else {
e.preventDefault();
mainWindow.hide();
}
});
示例3:
electron.ipcMain.on("ready-to-quit", (event) => {
if (event.sender !== mainWindow.webContents) return;
SupAppIPC.saveAuthorizations(userDataPath);
console.log("Exited cleanly.");
isReadyToQuit = true;
electron.app.quit();
});
示例4: isSquirrelEvent
public static isSquirrelEvent(): boolean {
if (process.argv.length === 1) {
return false;
}
const path = require('path');
const updateExe: string = path.resolve(path.dirname(process.execPath), '..', 'Update.exe');
const execName: string = path.basename(process.execPath);
const spawn = require('child_process').spawn;
const runUpdater = (args: string[], done: any) => {
return spawn(updateExe, args, { detached: true }).on('close', done);
};
const app = require('electron').app;
switch (process.argv[1]) {
case '--squirrel-install':
case '--squirrel-updated':
// Optionally do things such as:
// - Add your .exe to the PATH
// - Write to the registry for things like file associations and
// explorer context menus
// Install desktop and start menu shortcuts
runUpdater(['--createShortcut', execName], app.quit);
return true;
case '--squirrel-uninstall':
// Undo anything you did in the --squirrel-install and
// --squirrel-updated handlers
// Remove desktop and start menu shortcuts
runUpdater(['--removeShortcut', execName], app.quit);
return true;
case '--squirrel-obsolete':
// This is called on the outgoing version of your app before
// we update to the new version - it's the opposite of
// --squirrel-updated
app.quit();
return true;
case '--squirrel-firstrun':
// Delay to give time to the installGif to close
let delayed = new Date().getTime() + (3 * 1000);
while (new Date().getTime() <= delayed) {
// do events
}
return false;
}
return false;
}
示例5: function
browserWindow.on("closed", function() {
action(() =>
windows.splice(windows.findIndex(win => win.browserWindow === browserWindow), 1)
)();
// if no visible window left, app can quit
if (!windows.find(window => window.browserWindow.isVisible())) {
app.quit();
}
});
示例6:
app.on('window-all-closed', () => {
env.log('Lifecycle#window-all-closed');
// Windows/Linux: we quit when all windows have closed
// Mac: we only quit when quit was requested
// Tests: we always quit
if (this.quitRequested || process.platform !== 'darwin') {
app.quit();
}
});
示例7:
app.on('window-all-closed', () => {
env.log('Lifecycle#window-all-closed');
// Windows/Linux: we quit when all windows have closed
// Mac: we only quit when quit was requested
// --wait: we quit when all windows are closed
if (this.quitRequested || process.platform !== 'darwin' || env.cliArgs.waitForWindowClose) {
app.quit();
}
});
示例8:
app.on("window-all-closed", () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
// if (process.platform !== "darwin") {
// app.quit();
// }
app.quit();
});
示例9: setupTrayOrDock
i18n.load([ "startup", "tray" ], () => {
if (dataPathErr != null) {
electron.dialog.showErrorBox(i18n.t("startup:failedToStart"), i18n.t(dataPathErr.key, dataPathErr.variables));
electron.app.quit();
process.exit(1);
return;
}
setupTrayOrDock();
setupMainWindow();
});
示例10:
Electron.app.on("window-all-closed", () => {
config.save();
environment.save();
repoSessions.dispose();
const devtools = Electron.BrowserWindow.getDevToolsExtensions() as {
[name: string]: any;
};
Object.keys(devtools).map(Electron.BrowserWindow.removeDevToolsExtension);
if (process.platform !== "darwin") {
Electron.app.quit();
}
});