bump electron package dep and prevent multiple instances

master
Dave Conway-Jones 2021-01-31 16:23:55 +00:00
rodzic ac98d1cc3d
commit 794b47c67e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 88BA2B8A411BE9FF
2 zmienionych plików z 22 dodań i 6 usunięć

24
main.js
Wyświetl plik

@ -50,6 +50,9 @@ const BrowserWindow = electron.BrowserWindow;
const Tray = electron.Tray;
const { TouchBarButton, TouchBarSpacer } = TouchBar;
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) { console.log("Second instance - quitting."); app.quit(); }
var RED = require("node-red");
var red_app = express();
@ -123,7 +126,7 @@ console.log("FlowFile :",flowfile);
// Keep a global reference of the window objects, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
let mainWindow = null;
let conWindow;
let tray;
let logBuffer = [];
@ -496,9 +499,22 @@ function createTray() {
}
// Called when Electron has finished initialization and is ready to create browser windows.
app.on('ready', () => {
createTray()
createWindow()
// app.on('ready', () => {
// createTray()
// myWindow = createWindow()
// })
app.whenReady().then(() => {
createTray();
createWindow();
})
app.on('second-instance', (event, commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
if (mainWindow.isMinimized()) { mainWindow.restore(); }
mainWindow.focus();
}
})
// Quit when all windows are closed.

Wyświetl plik

@ -27,7 +27,7 @@
},
"dependencies": {
"electron-is-dev": "^1.2.0",
"electron-store": "^6.0.0",
"electron-store": "^7.0.0",
"express": "^4.17.1",
"node-red": "1.2.7",
"node-red-contrib-play-audio": "*",
@ -53,7 +53,7 @@
},
"homepage": "https://github.com/dceejay/electron-node-red#readme",
"devDependencies": {
"electron": "~10.1.5",
"electron": "~11.2.1",
"electron-builder": "^22.9.1"
},
"build": {