config loading
This commit is contained in:
@@ -3,8 +3,8 @@ https://www.electronjs.org/docs/latest/tutorial/quick-start
|
|||||||
# Dev environment
|
# Dev environment
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
sudp apt install node
|
sudo apt install node
|
||||||
sudp apt install npm
|
sudo apt install npm
|
||||||
sudo apt install rpm
|
sudo apt install rpm
|
||||||
|
|
||||||
npm install
|
npm install
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"url": "https://annahöfe.sign.tooloop.de/de/screens/annahof"
|
"url": "https://www.tooloop.de"
|
||||||
}
|
}
|
||||||
+27
-9
@@ -1,19 +1,37 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Hello World!</title>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
|
<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>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>Hello World!</h1>
|
<h1>Tooloop Kiosk Browser</h1>
|
||||||
<p>
|
<p>www.tooloop.de</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>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@@ -1,29 +1,27 @@
|
|||||||
const { app, BrowserWindow } = require('electron/main')
|
const { app, BrowserWindow } = require('electron/main');
|
||||||
const path = require('node:path')
|
const path = require('node:path');
|
||||||
const fs = require("fs");
|
const fs = require('fs');
|
||||||
|
// const http = require('http');
|
||||||
|
|
||||||
|
|
||||||
let url = 'https://www.tooloop.de';
|
|
||||||
let config;
|
let config;
|
||||||
let mainWindow;
|
let win;
|
||||||
|
|
||||||
|
|
||||||
function loadConfig() {
|
function loadConfig() {
|
||||||
fs.readFile(path.join(__dirname, "config.json"), "utf8", (error, data) => {
|
try {
|
||||||
if (error) {
|
const data = fs.readFileSync(path.join(__dirname, "config.json"), { encoding: 'utf8' });
|
||||||
console.log(error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
config = JSON.parse(data);
|
config = JSON.parse(data);
|
||||||
console.log(config);
|
} catch (err) {
|
||||||
});
|
console.log(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function createWindow() {
|
async function createWindow() {
|
||||||
mainWindow = new BrowserWindow({
|
win = new BrowserWindow({
|
||||||
width: 1920,
|
width: 1920,
|
||||||
height: 1080,
|
height: 1080,
|
||||||
|
backgroundColor: '#000000',
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, 'preload.js'),
|
preload: path.join(__dirname, 'preload.js'),
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
@@ -33,18 +31,36 @@ function createWindow() {
|
|||||||
autoHideMenuBar: true
|
autoHideMenuBar: true
|
||||||
});
|
});
|
||||||
|
|
||||||
mainWindow.loadFile('index.html');
|
win.on("closed", function () {
|
||||||
// mainWindow.loadURL(url);
|
win = null;
|
||||||
|
|
||||||
mainWindow.on("closed", function () {
|
|
||||||
mainWindow = null;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
mainWindow.once("ready-to-show", () => {
|
win.once("ready-to-show", () => {
|
||||||
mainWindow.setKiosk(true);
|
win.setKiosk(true);
|
||||||
mainWindow.show();
|
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(() => {
|
app.whenReady().then(() => {
|
||||||
@@ -59,7 +75,5 @@ app.whenReady().then(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
if (process.platform !== 'darwin') {
|
app.quit()
|
||||||
app.quit()
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
+1
-1
@@ -33,4 +33,4 @@
|
|||||||
"@electron/fuses": "^1.8.0",
|
"@electron/fuses": "^1.8.0",
|
||||||
"electron": "30.0.8"
|
"electron": "30.0.8"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user