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"
}
+23 -18
View File
@@ -25,7 +25,11 @@ 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) {
console.error(err); if (err.code == 'ENOENT') {
console.warn('No config file found.');
} else {
console.error(err);
}
} }
} }
@@ -59,24 +63,25 @@ async function createWindow() {
win.loadFile('index.html'); win.loadFile('index.html');
try { if (config != undefined) {
let url = new URL(config.url); try {
// let options = { let url = new URL(config.url);
// method: 'HEAD', // let options = {
// host: url.hostname, // method: 'HEAD',
// port: url.port ? url.port : 80, // host: url.hostname,
// path: '/' // port: url.port ? url.port : 80,
// }; // path: '/'
// let req = http.request(options, function (r) { // };
// log.info(r.headers); // let req = http.request(options, function (r) {
// }); // log.info(r.headers);
// req.end(); // });
// req.end();
win.loadURL(config.url); win.loadURL(config.url);
} 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;
} }