From 3c4441e8c5ac1f10aa14f560a7fa07ea9e60ca28 Mon Sep 17 00:00:00 2001 From: vapormusic Date: Thu, 6 Jan 2022 21:06:48 +0700 Subject: [PATCH] catch if components fail (ms builds) --- index.js | 55 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index c3358359..1d12b7d2 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,7 @@ require('v8-compile-cache'); const {app, components} = require('electron'), {resolve, join} = require("path"), CiderBase = require('./src/main/cider-base'); - +var componentsFail = false; // Analytics for debugging. const ElectronSentry = require("@sentry/electron"); ElectronSentry.init({dsn: "https://68c422bfaaf44dea880b86aad5a820d2@o954055.ingest.sentry.io/6112214"}); @@ -138,26 +138,30 @@ if (process.platform === "linux") { app.on('ready', () => { app.whenReady().then(async () => { - await components.whenReady().catch(e => console.log(`component ready fail:`, e)); - console.log('components ready:', components.status()); - if (app.isQuiting) { - app.quit(); - return; - } - app.commandLine.appendSwitch('high-dpi-support', 1) - app.commandLine.appendSwitch('force-device-scale-factor', 1) - app.commandLine.appendSwitch('disable-pinch'); + if (components != null) { + try{ + await components.whenReady().catch(e => {console.log(`component ready fail:`, e); componentsFail = true}); + console.log('components ready:', components.status()); + if (app.isQuiting) { + app.quit(); + return; + } + app.commandLine.appendSwitch('high-dpi-support', 1) + app.commandLine.appendSwitch('force-device-scale-factor', 1) + app.commandLine.appendSwitch('disable-pinch'); - console.log('[Cider] Application is Ready. Creating Window.') - if (!app.isPackaged) { - console.info('[Cider] Running in development mode.') - require('vue-devtools').install() - } - CreateWindow() + console.log('[Cider] Application is Ready. Creating Window.') + if (!app.isPackaged) { + console.info('[Cider] Running in development mode.') + require('vue-devtools').install() + } + CreateWindow() + } catch (e) {componentsFail = true} + } else {componentsFail = true} }) }); -app.on('before-quit', () => { +app.on('before-quit', () => {s app.isQuiting = true; console.warn(`${app.getName()} exited.`); }); @@ -169,6 +173,23 @@ app.on('widevine-ready', (version, lastVersion) => { } else { console.log('[Cider][Widevine] Widevine ' + version + ' is ready to be used!') } + + if(componentsFail){ + if (app.isQuiting) { + app.quit(); + return; + } + app.commandLine.appendSwitch('high-dpi-support', 1) + app.commandLine.appendSwitch('force-device-scale-factor', 1) + app.commandLine.appendSwitch('disable-pinch'); + + console.log('[Cider] Application is Ready. Creating Window.') + if (!app.isPackaged) { + console.info('[Cider] Running in development mode.') + require('vue-devtools').install() + } + CreateWindow() + } }) app.on('widevine-update-pending', (currentVersion, pendingVersion) => {