Skip to content

Commit b05f108

Browse files
committed
One instance
1 parent c27df9f commit b05f108

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/main.dev.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ export default class AppUpdater {
3434

3535
let mainWindow: BrowserWindow | null = null;
3636

37+
const gotTheLock = app.requestSingleInstanceLock();
38+
39+
if (!gotTheLock) {
40+
app.quit();
41+
} else {
42+
app.on('second-instance', () => {
43+
// Someone tried to run a second instance, we should focus our window.
44+
if (mainWindow) {
45+
if (mainWindow.isMinimized()) {
46+
mainWindow.restore();
47+
}
48+
mainWindow.focus();
49+
}
50+
});
51+
}
52+
3753
if (process.env.NODE_ENV === 'production') {
3854
const sourceMapSupport = require('source-map-support');
3955
sourceMapSupport.install();

0 commit comments

Comments
 (0)