config loading

This commit is contained in:
2024-05-28 16:43:25 +02:00
parent bae9cf8d53
commit d51d857b88
5 changed files with 71 additions and 39 deletions
+2 -2
View File
@@ -3,8 +3,8 @@ https://www.electronjs.org/docs/latest/tutorial/quick-start
# Dev environment
```bash
sudp apt install node
sudp apt install npm
sudo apt install node
sudo apt install npm
sudo apt install rpm
npm install
+1 -1
View File
@@ -1,3 +1,3 @@
{
"url": "https://annahöfe.sign.tooloop.de/de/screens/annahof"
"url": "https://www.tooloop.de"
}
+27 -9
View File
@@ -1,19 +1,37 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tooloop Kiosk Browser</title>
<style>
* {
font-family: system-ui, sans-serif;
font-weight: lighter;
}
html,
body {
background-color: black;
display: flex;
height: 100%;
width: 100%;
align-items: center;
justify-content: center;
flex-direction: column;
}
h1, p {
color: darkslateblue;
margin: 0.25em;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
<p>
We are using Node.js <span id="node-version"></span>,
Chromium <span id="chrome-version"></span>,
and Electron <span id="electron-version"></span>.
</p>
<h1>Tooloop Kiosk Browser</h1>
<p>www.tooloop.de</p>
</body>
</html>
+40 -26
View File
@@ -1,29 +1,27 @@
const { app, BrowserWindow } = require('electron/main')
const path = require('node:path')
const fs = require("fs");
const { app, BrowserWindow } = require('electron/main');
const path = require('node:path');
const fs = require('fs');
// const http = require('http');
let url = 'https://www.tooloop.de';
let config;
let mainWindow;
let win;
function loadConfig() {
fs.readFile(path.join(__dirname, "config.json"), "utf8", (error, data) => {
if (error) {
console.log(error);
return;
}
try {
const data = fs.readFileSync(path.join(__dirname, "config.json"), { encoding: 'utf8' });
config = JSON.parse(data);
console.log(config);
});
} catch (err) {
console.log(err);
}
}
function createWindow() {
mainWindow = new BrowserWindow({
async function createWindow() {
win = new BrowserWindow({
width: 1920,
height: 1080,
backgroundColor: '#000000',
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: true,
@@ -33,18 +31,36 @@ function createWindow() {
autoHideMenuBar: true
});
mainWindow.loadFile('index.html');
// mainWindow.loadURL(url);
mainWindow.on("closed", function () {
mainWindow = null;
win.on("closed", function () {
win = null;
});
mainWindow.once("ready-to-show", () => {
mainWindow.setKiosk(true);
mainWindow.show();
win.once("ready-to-show", () => {
win.setKiosk(true);
win.show();
});
win.loadFile('index.html');
try {
let url = new URL(config.url);
// let options = {
// method: 'HEAD',
// host: url.hostname,
// port: url.port ? url.port : 80,
// path: '/'
// };
// let req = http.request(options, function (r) {
// console.log(r.headers);
// });
// req.end();
win.loadURL(config.url);
} catch (err) {
console.log(err);
} finally {
}
}
app.whenReady().then(() => {
@@ -59,7 +75,5 @@ app.whenReady().then(() => {
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
app.quit()
});
+1 -1
View File
@@ -33,4 +33,4 @@
"@electron/fuses": "^1.8.0",
"electron": "30.0.8"
}
}
}