// ElectronJS const {app, BrowserWindow, Menu, Notification} = require('electron') // Dependenies by Korbs Studio const glasstron = require('glasstron-clarity') const TitlebarRespect = require('electron-titlebar-respect') // Other dependenies const isDev = require('electron-is-dev') const log = require('electron-log') const Pushy = require('pushy-electron') // Needed for other stuff const path = require('path') let mainWindow // Grab .env options require('dotenv').config() // Override the console.log function with Electron Log log.transports.console.format = '\x1b[34m[electron]:\x1b[37m' console.log = log.log // Use the correct icon depending on the operating system if /* If macOS */ (process.platform === 'darwin') {global.AppIcon = 'public/images/icons/app/macOS.icns' } else if /* If Windows */ (process.platform === 'win32') {global.AppIcon = 'public/images/icons/app/Windows.png' } else /* If Linux */ {global.AppIcon = 'public/images/icons/app/Linux.png' } function createWindow () { mainWindow = new glasstron.BrowserWindow({ title: process.env.Name, minWidth: 400, minHeight: 400, width: 1200, height: 800, autoHideMenuBar: true, show: false, blur: true, frame: global.frame, titleBarStyle: global.titleBarStyle, icon: path.join(global.AppIcon), trafficLightPosition: { x: 25, y: 25 }, // Position of Traffic Light buttons on macOS titleBarOverlay: { // Background and Height of Windows titlebar buttons color: '#232323', // Background symbolColor: 'white', // Icon height: 44, }, webPreferences: { webviewTag: true } }) // Showing the window gracefuly // Doc: https://www.electronjs.org/docs/latest/api/browser-window#showing-the-window-gracefully mainWindow.once('ready-to-show', () => {mainWindow.show()}) // Set Platform Class if /* If macOS */ (process.platform === 'darwin') { mainWindow.webContents.executeJavaScript(`document.querySelector('html').setAttribute('os', 'Mac')`) } else if /* If Windows */ (process.platform === 'win32') { mainWindow.webContents.executeJavaScript(`document.querySelector('html').setAttribute('os', 'Windows')`) } else /* If Linux */ { mainWindow.webContents.executeJavaScript(`document.querySelector('html').setAttribute('os', 'Linux')`) } // Pushy - Pushy Notification System (PNS) mainWindow.webContents.on('did-finish-load', () => {Pushy.listen()}) Pushy.register({ appId: process.env.PushyAppId }).then((deviceToken) => {}).catch((error) => {console.log('Pushy registration error: ' + error.message)}) setTimeout(() => { Pushy.setNotificationListener((data) => { new Notification({ title: data.title, body: data.message }).show() if(process.env.NotificationType === 'Native') { new Notification({ title: data.title, body: data.message }).show() } else if(process.env.NotificationType === 'Custom') { mainWindow.webContents.executeJavaScript(` document.querySelector("body > div > div.sidebar > div.sidebar-bottom").insertAdjacentHTML("afterBegin",'
${data.title}