Add way to set flags for Electron before the app starts

This commit is contained in:
theolivenbaum
2021-09-07 14:36:57 +02:00
parent 801616cd53
commit dc2662e52e
5 changed files with 24 additions and 3 deletions

View File

@@ -539,9 +539,9 @@ namespace ElectronNET.API
public Task<string> GetNameAsync() => BridgeConnector.OnResult<string>("appGetName", "appGetNameCompleted");
internal App()
private App()
{
CommandLine = new CommandLine();
CommandLine = CommandLine.Instance;
}
internal static App Instance

View File

@@ -8,7 +8,7 @@ namespace ElectronNET.API
/// </summary>
public sealed class CommandLine
{
internal CommandLine() { }
private CommandLine() { }
internal static CommandLine Instance
{

View File

@@ -28,4 +28,10 @@ namespace ElectronNET.API.Entities
/// </summary>
customButtonsOnHover
}
public class TitleBarOverlayConfig
{
public string Color { get; set; }
public string SymbolColor { get; set; }
}
}

View File

@@ -171,6 +171,12 @@ namespace ElectronNET.API.Entities
/// </summary>
public bool Offscreen { get; set; }
/// <summary>
/// Whether to enable built-in spellcheck
/// </summary>
[DefaultValue(true)]
public bool Spellcheck { get; set; } = true;
/// <summary>
/// Whether to run Electron APIs and the specified preload script in a separate
/// JavaScript context. Defaults to false. The context that the preload script runs

View File

@@ -54,6 +54,7 @@ app.on('before-quit-for-update', () => {
});
const manifestJsonFile = require(manifestJsonFilePath);
if (manifestJsonFile.singleInstance || manifestJsonFile.aspCoreBackendPort) {
const mainInstance = app.requestSingleInstanceLock();
app.on('second-instance', (events, args = []) => {
@@ -81,6 +82,14 @@ if (manifestJsonFile.singleInstance || manifestJsonFile.aspCoreBackendPort) {
}
}
//Some flags need to be set before app is ready
if (manifestJsonFile.hasOwnProperty('cliFlags') && manifesJsonFile.cliFlags.length > 0) {
manifestJsonFile.cliFlags.forEach(flag => {
app.commandLine.appendSwitch(flag);
});
}
app.on('ready', () => {
// Fix ERR_UNKNOWN_URL_SCHEME using file protocol