From 906c09289fba75ab0d8059b447d4d2a4cd638cbe Mon Sep 17 00:00:00 2001 From: Oj Date: Tue, 19 Apr 2022 23:06:34 +0100 Subject: [PATCH] [Utils > Win] Redo to use only 2 args based on name/type --- src/config/index.js | 3 +-- src/splash/index.js | 3 +-- src/utils/win.js | 16 +++++----------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/config/index.js b/src/config/index.js index 1676e88..f157475 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -1,5 +1,4 @@ const { ipcMain, app } = require('electron'); -const { join } = require('path'); ipcMain.on('DISCORD_UPDATED_QUOTES', (e, c) => { if (c === 'o') open(); @@ -9,7 +8,7 @@ const open = exports.open = () => { const win = require('../utils/win')({ width: 500, height: 650 - }, join(__dirname, 'preload.js'), 'config'); + }, 'config'); let config = settings.get('openasar', {}); config.setup = true; diff --git a/src/splash/index.js b/src/splash/index.js index 8473031..0c89d1f 100644 --- a/src/splash/index.js +++ b/src/splash/index.js @@ -1,4 +1,3 @@ -const { join } = require('path'); const { app } = require('electron'); const moduleUpdater = require("../updater/moduleUpdater"); @@ -68,7 +67,7 @@ const launchSplash = (startMin) => { win = require('../utils/win')({ width: 300, height: process.platform === 'darwin' ? 300 : 350 - }, join(__dirname, 'preload.js'), 'splash'); + }, 'splash'); if (process.platform !== 'darwin') win.on('closed', () => !launchedMainWindow && app.quit()); diff --git a/src/utils/win.js b/src/utils/win.js index 4963a3c..622a239 100644 --- a/src/utils/win.js +++ b/src/utils/win.js @@ -1,18 +1,12 @@ -const { BrowserWindow } = require('electron'); - -const paths = require('../paths'); -const fs = require('fs'); - - -module.exports = (o, preload, u) => { - const w = new BrowserWindow({ +module.exports = (o, n) => { + const w = new (require('electron').BrowserWindow)({ center: true, frame: false, resizable: false, center: true, backgroundColor: '#2f3136', webPreferences: { - preload + preload: require('path').join(__dirname, '..', n, 'preload.js') }, ...o }); @@ -20,11 +14,11 @@ module.exports = (o, preload, u) => { const c = w.webContents; c.once('dom-ready', () => { if (oaConfig.themeSync !== false) try { - c.insertCSS(JSON.parse(fs.readFileSync(join(paths.getUserData(), 'userDataCache.json'), 'utf8')).openasarSplashCSS); + c.insertCSS(JSON.parse(require('fs').readFileSync(join(require('../paths').getUserData(), 'userDataCache.json'), 'utf8')).openasarSplashCSS); } catch { } }); - w.loadURL('https://cdn.openasar.dev/' + u); + w.loadURL('https://cdn.openasar.dev/' + n); return w; }; \ No newline at end of file