本文整理汇总了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 */);
};
示例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 */);
};
示例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') {
示例4: function
globals.FrontendDaemon.on('exit', function() {
console.log('Frontend has exited.')
elc.app.exit()
})
示例5: setTimeout
setTimeout(function() {
elc.app.exit()
}, 3000) // Hard limit - if it doesn't shut down in 3 seconds, we force kill it.
示例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/**',
示例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();
});
示例8: async
watcher.on(actions.quit, async (store, action) => {
app.exit(0);
});
示例9:
const quit = () => {
settings.persistToFile();
app.exit();
};
示例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