本文整理汇总了TypeScript中electron.app.requestSingleInstanceLock方法的典型用法代码示例。如果您正苦于以下问题:TypeScript app.requestSingleInstanceLock方法的具体用法?TypeScript app.requestSingleInstanceLock怎么用?TypeScript app.requestSingleInstanceLock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron.app
的用法示例。
在下文中一共展示了app.requestSingleInstanceLock方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: quit
const checkSingleInstance = () => {
if (process.mas) {
isFirstInstance = true;
} else {
isFirstInstance = app.requestSingleInstanceLock();
if (!EnvironmentUtil.platform.IS_WINDOWS && !isFirstInstance) {
quit();
} else {
app.on('second-instance', () => WindowManager.showPrimaryWindow());
}
}
};
示例2: handlePotentialProtocolLaunch
export const listenForProtocolHandler = () => {
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) app.quit();
app.on('open-url', (_, url) => {
if (url.startsWith(`${PROTOCOL}://`)) {
handlePotentialProtocolLaunch(url);
}
});
if (process.platform === 'win32') {
scanArgv(process.argv);
}
};
示例3: setInterval
autoUpdater.logger = log;
const FOUR_HOURS = 1000 * 60 * 60 * 4;
setInterval(() => {
autoUpdater.checkForUpdates();
}, FOUR_HOURS);
autoUpdater.checkForUpdates();
}
let mainWindow: BrowserWindow;
let isQuitting = false;
let prevMessageCount = 0;
let dockMenu: Menu;
if (!app.requestSingleInstanceLock()) {
app.quit();
}
app.on('second-instance', () => {
if (mainWindow) {
if (mainWindow.isMinimized()) {
mainWindow.restore();
}
mainWindow.show();
}
});
function updateBadge(conversations: Conversation[]): void {
// Ignore `Sindre messaged you` blinking
示例4:
import { backgroundJob } from './background-job';
import { backgroundService } from './background-service';
import { app, ipcMain, powerMonitor } from 'electron';
import { logManager } from './log-manager';
let logger = logManager.getLogger('AppIndex');
import AppManager from './app-manager';
import WindowManager from './window-manager';
import { extensionsManager } from './extensions-manager';
import AppUpdater from './app-updater';
import config from './config';
/* Single Instance Check */
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
logger.info('Quiting instance.');
app.quit();
} else {
app.on('second-instance', (event, commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
logger.info('Make single instance');
WindowManager.openMainWindow();
});
AppUpdater.init();
if (config.isDev) {
// const reloadFile = path.join(config.client);
// require('electron-reload')(reloadFile);