diff options
Diffstat (limited to 'app.js')
-rw-r--r-- | app.js | 143 |
1 files changed, 62 insertions, 81 deletions
@@ -21,6 +21,7 @@ global.start = new Date(); global.KartikRoot = __dirname; global.shouldExitIfClosed = false; const { app, BrowserWindow } = require('electron'); +const fs = require("fs"); (async () => { process.on('uncaughtException', (error) => { @@ -179,47 +180,9 @@ const { app, BrowserWindow } = require('electron'); /* --------------------- */ - console.log(" * Checking channel"); require('@electron/remote/main').initialize(); function createWindow () { - if (require('./package.json').channel === "stable") { - logo = "logo/logo.png"; - channel = " "; - global.dimg = "official"; - global.dimga = "stable"; - global.dchan = "Kartik Stable"; - } else if (require('./package.json').channel === "beta") { - logo = "logo/logo-beta.png"; - channel = " Beta "; - global.dimg = "beta"; - global.dimga = "beta"; - global.dchan = "Kartik Beta"; - } else if (require('./package.json').channel === "nightly") { - logo = "logo/logo-nightly.png"; - channel = " Nightly "; - global.dimg = "nightly"; - global.dimga = "nightly"; - global.dchan = "Kartik Nightly"; - } else if (require('./package.json').channel === "eap") { - logo = "logo/logo-eap.png"; - channel = " EAP "; - global.dimg = "eap"; - global.dimga = "eap"; - global.dchan = "Kartik EAP"; - } else if (require('./package.json').channel === "git") { - logo = "logo/logo-git.png"; - channel = " Trunk "; - global.dimg = "git"; - global.dimga = "git"; - global.dchan = "Kartik Trunk"; - try { - pk = require('./package.json'); - pk.version = require('fs').readFileSync("./.git/refs/heads/trunk").toString().substr(0, 7); - fs.writeFileSync("./package.json", JSON.stringify(pk, 2)) - } catch (e) {} - } - console.log(" * Checking configuration"); lp = currentNest.config.lang @@ -227,30 +190,6 @@ const { app, BrowserWindow } = require('electron'); time = new Date() - start; console.log(" * Started successfully in " + Math.round(time/1000) + " seconds"); console.log(" * Why are you EVEN reading this?"); - try { load.close(); } catch (e) {} - console.log(" * Starting recovery procedure: E_PROMISE"); - global.win = new BrowserWindow({ - width: 1220, - height: 720, - minWidth: 720, - minHeight: 540, - resizeable: true, - resizable: true, - maximizable: true, - show: false, - enableLargerThanScreen: true, - icon: logo, - backgroundColor: "#000000", - title: "Kartik", - webPreferences: { - nodeIntegration: true, - contextIsolation: false, - enableRemoteModule: true, - webviewTag: true, - disableBlinkFeatures: "MediaSessionService", - } - }) - global.shouldExitIfClosed = true; console.log(" * Starting IPC engine"); @@ -289,10 +228,6 @@ const { app, BrowserWindow } = require('electron'); console.log(" * Starting Discord RPC"); require('./discord/client.js'); - console.log(" * Loading view"); - win.loadFile('./index.html') - win.setMenu(null); - if (win.debug) { console.log(" * *******************************************"); console.log(" * * KARTIK DEBUG MODE *"); @@ -300,6 +235,10 @@ const { app, BrowserWindow } = require('electron'); win.openDevTools(); } + setTimeout(() => { + win.webContents.send('ready', true); + }, 3000) + win.webContents.on('dom-ready', () => { musicIpc = require('electron').ipcMain; musicIpc.on('newmusic', (event, value) => { @@ -351,17 +290,57 @@ const { app, BrowserWindow } = require('electron'); } console.log(" * Starting splash screen"); - global.load = new BrowserWindow({ - width: 640, - height: 400, - resizeable: false, - resizable: false, - maximizable: false, - frame: false, + + console.log(" * Checking channel"); + if (require('./package.json').channel === "stable") { + logo = "logo/logo.png"; + channel = " "; + global.dimg = "official"; + global.dimga = "stable"; + global.dchan = "Kartik Stable"; + } else if (require('./package.json').channel === "beta") { + logo = "logo/logo-beta.png"; + channel = " Beta "; + global.dimg = "beta"; + global.dimga = "beta"; + global.dchan = "Kartik Beta"; + } else if (require('./package.json').channel === "nightly") { + logo = "logo/logo-nightly.png"; + channel = " Nightly "; + global.dimg = "nightly"; + global.dimga = "nightly"; + global.dchan = "Kartik Nightly"; + } else if (require('./package.json').channel === "eap") { + logo = "logo/logo-eap.png"; + channel = " EAP "; + global.dimg = "eap"; + global.dimga = "eap"; + global.dchan = "Kartik EAP"; + } else if (require('./package.json').channel === "git") { + logo = "logo/logo-git.png"; + channel = " Trunk "; + global.dimg = "git"; + global.dimga = "git"; + global.dchan = "Kartik Trunk"; + try { + pk = require('./package.json'); + pk.version = require('fs').readFileSync("./.git/refs/heads/trunk").toString().substr(0, 7); + fs.writeFileSync("./package.json", JSON.stringify(pk, 2)) + } catch (e) {} + } + + global.win = new BrowserWindow({ + width: 1220, + height: 720, + minWidth: 720, + minHeight: 540, + resizeable: true, + resizable: true, + maximizable: true, show: false, enableLargerThanScreen: true, - icon: "logo/logo.png", - backgroundColor: "#4b4e50", + icon: logo, + backgroundColor: "#000000", title: "Kartik", webPreferences: { nodeIntegration: true, @@ -371,10 +350,12 @@ const { app, BrowserWindow } = require('electron'); disableBlinkFeatures: "MediaSessionService", } }) - load.loadFile("./views/load.html"); - load.webContents.once('dom-ready', () => { + console.log(" * Loading view"); + win.loadFile('./index.html') + win.setMenu(null); + win.webContents.once('dom-ready', () => { console.log(" * Showing splash screen"); - load.show(); + win.show(); setTimeout(() => { console.log(" * Checking signatures"); @@ -396,7 +377,7 @@ const { app, BrowserWindow } = require('electron'); } processed++; - load.webContents.send('progress', (processed/total)*100); + win.webContents.send('progress', (processed/total)*100); } for (file in sigdb["v2"]) { if (fs.existsSync(file) && !invalidfiles.includes(file)) { @@ -411,7 +392,7 @@ const { app, BrowserWindow } = require('electron'); } processed++; - load.webContents.send('progress', (processed/total)*100); + win.webContents.send('progress', (processed/total)*100); } for (file in sigdb["v3"]) { if (fs.existsSync(file) && !invalidfiles.includes(file)) { @@ -426,7 +407,7 @@ const { app, BrowserWindow } = require('electron'); } processed++; - load.webContents.send('progress', (processed/total)*100); + win.webContents.send('progress', (processed/total)*100); } global.importedTypeScriptFiles = []; |