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
+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()
});