diff --git a/README.md b/README.md index 8e28732..8c0dfc1 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/config.json b/config.json index 25407c6..5d7a278 100644 --- a/config.json +++ b/config.json @@ -1,3 +1,3 @@ { - "url": "https://annahöfe.sign.tooloop.de/de/screens/annahof" + "url": "https://www.tooloop.de" } \ No newline at end of file diff --git a/index.html b/index.html index 978086c..4b90ff9 100644 --- a/index.html +++ b/index.html @@ -1,19 +1,37 @@ - + - Hello World! - + + Tooloop Kiosk Browser + -

Hello World!

-

- We are using Node.js , - Chromium , - and Electron . -

+

Tooloop Kiosk Browser

+

www.tooloop.de

\ No newline at end of file diff --git a/main.js b/main.js index 044048f..7a37e54 100644 --- a/main.js +++ b/main.js @@ -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() }); \ No newline at end of file diff --git a/package.json b/package.json index c295607..50c9314 100644 --- a/package.json +++ b/package.json @@ -33,4 +33,4 @@ "@electron/fuses": "^1.8.0", "electron": "30.0.8" } -} \ No newline at end of file +}