singleInstance handle command line arguments

This commit is contained in:
Gregor Biswanger
2021-07-02 16:50:48 +02:00
parent 0e22ee3fd3
commit afcd113675
2 changed files with 12 additions and 1 deletions

View File

@@ -50,7 +50,17 @@ app.on('will-finish-launching', () => {
const manifestJsonFile = require(manifestJsonFilePath);
if (manifestJsonFile.singleInstance || manifestJsonFile.aspCoreBackendPort) {
const mainInstance = app.requestSingleInstanceLock();
app.on('second-instance', () => {
app.on('second-instance', (events, args = []) => {
args.forEach(parameter => {
const words = parameter.split('=');
if(words.length > 1) {
app.commandLine.appendSwitch(words[0].replace('--', ''), words[1]);
} else {
app.commandLine.appendSwitch(words[0].replace('--', ''));
}
});
const windows = BrowserWindow.getAllWindows();
if (windows.length) {
if (windows[0].isMinimized()) {