1
Fork 0

Prefer dotenv and pull data from it

This commit is contained in:
KorbsStudio 2023-02-13 13:57:11 -05:00
parent cef5cc5ff7
commit 8827de86ef
No known key found for this signature in database
3 changed files with 76 additions and 62 deletions

24
.env
View file

@ -1 +1,25 @@
#######################
# Metadata #
#######################
# Branding
Name="App Name"
Description="The description of the application."
AppId="net.company.appname"
Company="Company Name"
# Sources
Website="https://mycompany.net/"
Support="https://mycompany.net/help/"
SourceCode="https://github.com/company/app-name"
#######################
# App Configuration #
#######################
# Theming
## Splash
LoadingIndicator="Spinner" # "Spinner" "ProgressBar" "JumpingBalls" "GlowingBars"
Background="#232323"
# Notifications
## Pushy
PushyAppId="YourAppIdHere"

View file

@ -1,15 +1,21 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// PLEASE DO NOT TOUCH THIS FILE ///
/// This file is pulling data the ".env" file at the root of the project, please edit that file instead. ///
/// If your code editor shows the error "Property 'env' does not exist on type 'ImportMeta'.", please ignore. ///
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
export const APP = [{
name: "App Name",
website: "https://mycompany.net/",
support: "https://mycompany.net/help/",
sourcecode: "https://github.com/company/app-name"
name: import.meta.env.Name,
company: import.meta.env.Company,
website: import.meta.env.Website,
support: import.meta.env.Support,
sourcecode: import.meta.env.SourceCode
}]
// Splash
export const SPLASH = [
{
loading: "Spinner", // "Spinner" "ProgressBar" "JumpingBalls" "GlowingBars"
background: "#232323"
loading: import.meta.env.LoadingIndicator,
background: import.meta.env.Background
}
]
@ -17,41 +23,4 @@ export const SPLASH = [
/// Theming
export const SIDEBARTHEMING = [{
// Edit the "Configuration for Theming" section in the `styles/index.scss`.
}]
/// Top tabs of your sidbears
export const SIDEBARTOP = [
{
text: "Dashboard",
icon: "fa-solid fa-wand-magic-sparkles",
option: "active",
default: true
},
{
text: "Files",
icon: "fa-solid fa-folder-tree"
},
{
text: "Webview Demo",
icon: "fa-solid fa-globe"
},
{
text: "Webview Demo",
icon: "fa-solid fa-globe",
option: "has-navigation",
navigation: true
},
{
text: "iFrame Demo",
icon: "fa-solid fa-eye",
},
]
/// Bottoms tabs of your sidebar
export const SIDEBARBOTTOM = [
{
text: "Settings",
page: "Settings",
icon: "fa-solid fa-sliders",
}
]
}]

View file

@ -1,23 +1,34 @@
// ElectronJS
const {app, BrowserWindow, Menu} = require('electron')
const TitlebarRespect = require('electron-titlebar-respect')
const Pushy = require('pushy-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()
console.log(process.env.PushyAppId);
// 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: 'App Name',
title: process.env.Name,
minWidth: 400,
minHeight: 400,
width: 1200,
@ -53,7 +64,7 @@ function createWindow () {
document.querySelector("body > div > div.sidebar > div.sidebar-bottom").insertAdjacentHTML("afterBegin",'<li class="notification"><img class="notification-image" src="${data.image}"><i class="${data.icon}"></i><p class="notification-title">${data.title}</p><p class="notification-message">${data.message}</p><div class="notification-actions"><button id="primary" class="notification-action" onclick="shell.openExternal(${data.action})">Open</button><button id="secondary" class="notification-action">Dismiss</button></div></li>')
`)
})
}, 10000);
}, 10000)
if (Pushy.isRegistered()) {Pushy.subscribe('AppName').then(() => {}).catch((error) => {console.error(error)})}
@ -72,8 +83,6 @@ function createWindow () {
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'services' },
{ type: 'separator' },
{ role: 'hide' },
{ role: 'hideOthers' },
{ role: 'unhide' },
@ -124,9 +133,7 @@ function createWindow () {
{
label: 'Open WebView Developer Tools',
accelerator: 'CmdOrCtrl+Shift+W',
click: async () => {
mainWindow.webContents.executeJavaScript(`document.querySelector('.active webview').openDevTools()`)
}
click: async () => {if (isDev) {mainWindow.webContents.executeJavaScript(`document.querySelector('.active webview').openDevTools()`)}else {console.log('Not available in production mode.')}}
},
{ type: 'separator' },
{ role: 'resetZoom' },
@ -154,13 +161,27 @@ function createWindow () {
{
role: 'help',
submenu: [
{
label: 'Learn More',
click: async () => {
const { shell } = require('electron')
await shell.openExternal('https://code.korbsstudio.com/KorbsStudio/nexus-polestar')
}
{
label: 'Website',
click: async () => {
const { shell } = require('electron')
await shell.openExternal(process.env.Website)
}
},
{
label: 'Support',
click: async () => {
const { shell } = require('electron')
await shell.openExternal(process.env.Support)
}
},
{
label: 'Source Code',
click: async () => {
const { shell } = require('electron')
await shell.openExternal(process.env.SourceCode)
}
}
]
}
]
@ -173,7 +194,7 @@ function createWindow () {
app.whenReady().then(() => {
createWindow()
// DNS
// Doc: https://www.electronjs.org/docs/latest/api/app#appconfigurehostresolveroptions
// Docs: https://www.electronjs.org/docs/latest/api/app#appconfigurehostresolveroptions
app.configureHostResolver({
secureDnsMode: 'secure',
secureDnsServers: [