限制一个窗口

This commit is contained in:
wallace5303
2021-12-31 22:46:53 +08:00
parent b35fcd5997
commit b0942284a0
2 changed files with 16 additions and 1 deletions

15
main.js
View File

@@ -30,6 +30,21 @@ eggConfig.env = ENV
const eLogger = require('./electron/lib/eLogger').get()
async function initialize () {
// 限制一个窗口
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
helper.appQuit()
}
app.on('second-instance', (event) => {
if (MAIN_WINDOW) {
if (MAIN_WINDOW.isMinimized()) {
MAIN_WINDOW.restore()
}
MAIN_WINDOW.focus()
}
})
app.whenReady().then(() => {
createWindow()
app.on('activate', function () {