ignore config and include an example config instead

This commit is contained in:
2024-05-28 18:50:15 +02:00
parent 6a53286f67
commit 6102f3d4f6
4 changed files with 35 additions and 26 deletions
+2
View File
@@ -130,3 +130,5 @@ dist
.yarn/install-state.gz .yarn/install-state.gz
.pnp.* .pnp.*
# Tooloop
config.json
+10
View File
@@ -0,0 +1,10 @@
{
"url": "file:///assets/data/index.html",
"allowedDomains": [
"localhost",
"127.0.0.1",
"tooloop.de",
"www.tooloop.de"
],
"logPath": "/assets/logs/Tooloop-Kiosk-Browser.log"
}
-8
View File
@@ -1,8 +0,0 @@
{
"url": "https://www.tooloop.de",
"allowedDomains": [
"tooloop.de",
"www.tooloop.de"
],
"logPath": "/Users/vollstock/Arbeit/Playground/tooloop-kiosk-browser-logs/tooloop-kiosk-browser.log"
}
+7 -2
View File
@@ -25,8 +25,12 @@ function loadConfig() {
const data = fs.readFileSync(path.join(__dirname, "config.json"), { encoding: 'utf8' }); const data = fs.readFileSync(path.join(__dirname, "config.json"), { encoding: 'utf8' });
config = JSON.parse(data); config = JSON.parse(data);
} catch (err) { } catch (err) {
if (err.code == 'ENOENT') {
console.warn('No config file found.');
} else {
console.error(err); console.error(err);
} }
}
} }
/** /**
@@ -59,6 +63,7 @@ async function createWindow() {
win.loadFile('index.html'); win.loadFile('index.html');
if (config != undefined) {
try { try {
let url = new URL(config.url); let url = new URL(config.url);
// let options = { // let options = {
@@ -76,7 +81,7 @@ async function createWindow() {
} catch (err) { } catch (err) {
log.error(err); log.error(err);
} finally { }
} }
} }
@@ -103,7 +108,7 @@ app.whenReady().then(() => {
loadConfig(); loadConfig();
log.initialize(); log.initialize();
if ('logPath' in config) { if (config != undefined && 'logPath' in config) {
log.transports.file.resolvePathFn = () => config.logPath; log.transports.file.resolvePathFn = () => config.logPath;
} }