Skip to content

Commit b094228

Browse files
committed
限制一个窗口
1 parent b35fcd5 commit b094228

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

main.js

+15
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ eggConfig.env = ENV
3030
const eLogger = require('./electron/lib/eLogger').get()
3131

3232
async function initialize () {
33+
34+
// 限制一个窗口
35+
const gotTheLock = app.requestSingleInstanceLock()
36+
if (!gotTheLock) {
37+
helper.appQuit()
38+
}
39+
app.on('second-instance', (event) => {
40+
if (MAIN_WINDOW) {
41+
if (MAIN_WINDOW.isMinimized()) {
42+
MAIN_WINDOW.restore()
43+
}
44+
MAIN_WINDOW.focus()
45+
}
46+
})
47+
3348
app.whenReady().then(() => {
3449
createWindow()
3550
app.on('activate', function () {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "electron-egg",
3-
"version": "1.16.1",
3+
"version": "1.16.2",
44
"description": "A fast, desktop software development framework",
55
"main": "main.js",
66
"scripts": {

0 commit comments

Comments
 (0)