diff --git a/main.js b/main.js index 6f5d471..4413d3d 100644 --- a/main.js +++ b/main.js @@ -117,6 +117,15 @@ function createNotification(user) { mainWindow.focus(); } +// 处理单实例 +app.makeSingleInstance((commandLine, workingDirectory) => { + // Someone tried to run a second instance, we should focus our window. + if (mainWindow) { + if (mainWindow.isMinimized()) mainWindow.restore(); + mainWindow.focus(); + } +}); + app.on('ready', () => { const env = process.argv.find((arg) => arg.startsWith('--env='))?.split('=')[1]; if (env === 'development') {