mirror of
https://gitee.com/dromara/electron-egg.git
synced 2026-05-14 03:52:07 +08:00
限制一个窗口
This commit is contained in:
15
main.js
15
main.js
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user