mirror of
https://github.com/TheGreyDiamond/Enlight.git
synced 2025-07-18 04:33:50 +02:00
last
This commit is contained in:
87
index.js
87
index.js
@ -4,23 +4,52 @@ const { win32 } = require("path");
|
|||||||
const sysInf = require("systeminformation");
|
const sysInf = require("systeminformation");
|
||||||
|
|
||||||
var aWin2 = undefined;
|
var aWin2 = undefined;
|
||||||
var header = undefined;
|
|
||||||
|
|
||||||
header = fs.readFileSync("ui_templates/header.html").toString();
|
var preLoadedAmount = 0;
|
||||||
|
|
||||||
/// !!!-----------!!!
|
/// !!!-----------!!!
|
||||||
/// PAGE LOOKUP TABLE
|
/// PAGE LOOKUP TABLE
|
||||||
|
var preloadedPageLookup = {};
|
||||||
|
|
||||||
var pageLookup = {};
|
var pageLookup = {};
|
||||||
pageLookup["index"] = "index.html";
|
pageLookup["index"] = "index.html";
|
||||||
pageLookup["session"] = "sessions.html";
|
pageLookup["session"] = "sessions.html";
|
||||||
|
pageLookup["header"] = "header.html"
|
||||||
|
|
||||||
fs.readFile('ui_templates/sessions.html', 'utf8', function (err,data) {
|
|
||||||
|
|
||||||
|
for (const [key, value] of Object.entries(pageLookup)) {
|
||||||
|
// check if the property/key is defined in the object itself, not in parent
|
||||||
|
if (pageLookup.hasOwnProperty(key)) {
|
||||||
|
fs.readFile('ui_templates/' + value, 'utf8', function (err,data) {
|
||||||
|
preLoadedAmount++;
|
||||||
|
if (err) {
|
||||||
|
return console.log(err);
|
||||||
|
}
|
||||||
|
preloadedPageLookup[key] = data;
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadPage(name){
|
||||||
|
load = preloadedPageLookup[name]
|
||||||
|
if(load == undefined){
|
||||||
|
load = fs.readFileSync("ui_templates/" + pageLookup[name]).toString();
|
||||||
|
console.warn("Loading fallback for page " + name);
|
||||||
|
}
|
||||||
|
return(load)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
fs.readFile('ui_templates/index.html', 'utf8', function (err,data) {
|
||||||
|
preLoadedAmount++;
|
||||||
if (err) {
|
if (err) {
|
||||||
return console.log(err);
|
return console.log(err);
|
||||||
}
|
}
|
||||||
pageLookup["sessionPRELOAD"] = data;
|
preloadedPageLookup["index"] = data;
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
const win = new BrowserWindow({
|
const win = new BrowserWindow({
|
||||||
width: screen.getPrimaryDisplay().size.width,
|
width: screen.getPrimaryDisplay().size.width,
|
||||||
@ -32,7 +61,10 @@ function createWindow() {
|
|||||||
win.setFullScreen(true);
|
win.setFullScreen(true);
|
||||||
win.setMenuBarVisibility(false);
|
win.setMenuBarVisibility(false);
|
||||||
win.setAutoHideMenuBar(true);
|
win.setAutoHideMenuBar(true);
|
||||||
main = fs.readFileSync("ui_templates/index.html").toString();
|
main = loadPage("index")
|
||||||
|
header = loadPage("header")
|
||||||
|
|
||||||
|
//
|
||||||
//header = fs.readFileSync("ui_templates/header.html").toString();
|
//header = fs.readFileSync("ui_templates/header.html").toString();
|
||||||
toLoad = header + main;
|
toLoad = header + main;
|
||||||
fs.writeFileSync("ui_templates/temp.html", toLoad)
|
fs.writeFileSync("ui_templates/temp.html", toLoad)
|
||||||
@ -60,23 +92,29 @@ function createStartupInfo() {
|
|||||||
|
|
||||||
function doneLoading() {
|
function doneLoading() {
|
||||||
var fadeOutI = 1;
|
var fadeOutI = 1;
|
||||||
aWin2.webContents.executeJavaScript(
|
if(Object.keys(pageLookup).length == preLoadedAmount){
|
||||||
"document.getElementById('current').innerHTML = 'Done';"
|
aWin2.webContents.executeJavaScript(
|
||||||
);
|
"document.getElementById('current').innerHTML = 'Done';"
|
||||||
var fadeIntervall = setInterval(function () {
|
);
|
||||||
try {
|
var fadeIntervall = setInterval(function () {
|
||||||
if (fadeOutI < 0) {
|
try {
|
||||||
|
if (fadeOutI < 0) {
|
||||||
|
clearInterval(fadeIntervall);
|
||||||
|
aWin2.webContents.executeJavaScript("window.close()");
|
||||||
|
} else {
|
||||||
|
aWin2.setOpacity(fadeOutI);
|
||||||
|
fadeOutI = fadeOutI - 0.05;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("Startup window got destroyed!");
|
||||||
clearInterval(fadeIntervall);
|
clearInterval(fadeIntervall);
|
||||||
aWin2.webContents.executeJavaScript("window.close()");
|
|
||||||
} else {
|
|
||||||
aWin2.setOpacity(fadeOutI);
|
|
||||||
fadeOutI = fadeOutI - 0.05;
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
}, 20);
|
||||||
console.warn("Startup window got destroyed!");
|
}else{
|
||||||
clearInterval(fadeIntervall);
|
console.warn("Had to reschedule load finish")
|
||||||
}
|
setTimeout(doneLoading, 200);
|
||||||
}, 20);
|
}
|
||||||
|
|
||||||
//aWin2.webContents.executeJavaScript("window.close()")
|
//aWin2.webContents.executeJavaScript("window.close()")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,10 +179,9 @@ function init() {
|
|||||||
|
|
||||||
}else if (String(arg).includes("PAGE:change")) {
|
}else if (String(arg).includes("PAGE:change")) {
|
||||||
newPage = String(arg).split(".")[1]
|
newPage = String(arg).split(".")[1]
|
||||||
main = pageLookup[newPage + "PRELOAD"]
|
main = header = loadPage(newPage)
|
||||||
if(main == undefined){
|
|
||||||
main = fs.readFileSync("ui_templates/" + pageLookup[newPage]).toString();
|
header = loadPage("header")
|
||||||
}
|
|
||||||
toLoad = header + main;
|
toLoad = header + main;
|
||||||
fs.writeFileSync("ui_templates/temp.html", toLoad)
|
fs.writeFileSync("ui_templates/temp.html", toLoad)
|
||||||
win.loadFile("ui_templates/temp.html")
|
win.loadFile("ui_templates/temp.html")
|
||||||
|
10
package-lock.json
generated
10
package-lock.json
generated
@ -317,11 +317,6 @@
|
|||||||
"minimatch": "^3.0.4"
|
"minimatch": "^3.0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"font-awesome": {
|
|
||||||
"version": "4.7.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/font-awesome/-/font-awesome-4.7.0.tgz",
|
|
||||||
"integrity": "sha1-j6jPBBGhoxr9B7BtKQK7n8gVoTM="
|
|
||||||
},
|
|
||||||
"fs-extra": {
|
"fs-extra": {
|
||||||
"version": "8.1.0",
|
"version": "8.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
|
||||||
@ -752,6 +747,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||||
},
|
},
|
||||||
|
"yarn": {
|
||||||
|
"version": "1.22.10",
|
||||||
|
"resolved": "https://registry.npmjs.org/yarn/-/yarn-1.22.10.tgz",
|
||||||
|
"integrity": "sha512-IanQGI9RRPAN87VGTF7zs2uxkSyQSrSPsju0COgbsKQOOXr5LtcVPeyXWgwVa0ywG3d8dg6kSYKGBuYK021qeA=="
|
||||||
|
},
|
||||||
"yauzl": {
|
"yauzl": {
|
||||||
"version": "2.10.0",
|
"version": "2.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz",
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ejs": "^3.1.5",
|
"ejs": "^3.1.5",
|
||||||
"electron": "^11.0.2",
|
"electron": "^11.0.2",
|
||||||
"systeminformation": "^4.30.1"
|
"systeminformation": "^4.30.1",
|
||||||
|
"yarn": "^1.22.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user