clean up electron

This commit is contained in:
Felix Wiedenbach
2021-01-05 18:48:55 +01:00
parent 5d60534dc9
commit 4efe04774c

View File

@@ -5,7 +5,7 @@ const core = require("./app.js");
const Log = require("./logger.js");
// Config
var config = process.env.config ? JSON.parse(process.env.config) : {};
let config = process.env.config ? JSON.parse(process.env.config) : {};
// Module to control application life.
const app = electron.app;
// Module to create native browser window.
@@ -20,7 +20,7 @@ let mainWindow;
*/
function createWindow() {
app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required");
var electronOptionsDefaults = {
let electronOptionsDefaults = {
width: 800,
height: 600,
x: 0,
@@ -42,7 +42,7 @@ function createWindow() {
electronOptionsDefaults.autoHideMenuBar = true;
}
var electronOptions = Object.assign({}, electronOptionsDefaults, config.electronOptions);
const electronOptions = Object.assign({}, electronOptionsDefaults, config.electronOptions);
// Create the browser window.
mainWindow = new BrowserWindow(electronOptions);
@@ -50,14 +50,14 @@ function createWindow() {
// and load the index.html of the app.
// If config.address is not defined or is an empty string (listening on all interfaces), connect to localhost
var prefix;
let prefix;
if (config["tls"] !== null && config["tls"]) {
prefix = "https://";
} else {
prefix = "http://";
}
var address = (config.address === void 0) | (config.address === "") ? (config.address = "localhost") : config.address;
let address = (config.address === void 0) | (config.address === "") ? (config.address = "localhost") : config.address;
mainWindow.loadURL(`${prefix}${address}:${config.port}`);
// Open the DevTools if run with "npm start dev"
@@ -125,7 +125,7 @@ app.on("before-quit", (event) => {
// Start the core application if server is run on localhost
// This starts all node helpers and starts the webserver.
if (["localhost", "127.0.0.1", "::1", "::ffff:127.0.0.1", undefined].indexOf(config.address) > -1) {
if (["localhost", "127.0.0.1", "::1", "::ffff:127.0.0.1", undefined].includes(config.address)) {
core.start(function (c) {
config = c;
});