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

@@ -16,6 +16,7 @@ ElectronNET.API:
* Breaking API Changes (from native Electron 13.1.5):
- `Shell.MoveItemToTrashAsync` renamed with `Shell.TrashItemAsync`
- The deprecated extension APIs have been removed: `BrowserWindow.GetAllExtensionsAsync()`, `BrowserWindow.RemoveExtension()`, `BrowserWindow.AddExtensionAsync()`. Use the session APIs instead: `Session.GetAllExtensionsAsync()`, `Session.RemoveExtension()`, `Session.LoadExtensionAsync()`.
* New Feature: singleInstance handle command line arguments [\#520](https://github.com/ElectronNET/Electron.NET/issues/520)
* New Feature: Add WebContents [insertCSS](https://www.electronjs.org/docs/api/web-contents#contentsinsertcsscss-options) functionality (thanks [nfichter](https://github.com/nfichter)) [\#559](https://github.com/ElectronNET/Electron.NET/pull/559)
* New Feature: Allow IpcMain to send IPC messages to BrowserViews (thanks [nfichter](https://github.com/nfichter)) [\#560](https://github.com/ElectronNET/Electron.NET/pull/560)
* New Feature: Add support for proxies that require basic username/password authentication (thanks [nfichter](https://github.com/nfichter)) [\#561](https://github.com/ElectronNET/Electron.NET/pull/561)

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()) {