diff --git a/publish/changeLog.md b/publish/changeLog.md index 9c067645..9343f067 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -1,3 +1,7 @@ +### 新增 + +- 新增单例应用功能 + ### 优化 - 优化歌单列表动画 diff --git a/src/main/index.js b/src/main/index.js index f223b5bb..eb6ead83 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -1,6 +1,20 @@ const { app, BrowserWindow, Menu } = require('electron') const path = require('path') +// 单例应用程序 +if (!app.requestSingleInstanceLock()) { + app.quit() + return +} +app.on('second-instance', (event, argv, cwd) => { + if (mainWindow) { + if (mainWindow.isMinimized()) mainWindow.restore() + mainWindow.focus() + } else { + app.quit() + } +}) + require('./events') const progressBar = require('./events/progressBar') const trafficLight = require('./events/trafficLight') @@ -90,4 +104,3 @@ app.on('activate', () => { createWindow() } }) -