Prefer dotenv and pull data from it
This commit is contained in:
parent
cef5cc5ff7
commit
8827de86ef
3 changed files with 76 additions and 62 deletions
24
.env
24
.env
|
@ -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"
|
PushyAppId="YourAppIdHere"
|
|
@ -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 = [{
|
export const APP = [{
|
||||||
name: "App Name",
|
name: import.meta.env.Name,
|
||||||
website: "https://mycompany.net/",
|
company: import.meta.env.Company,
|
||||||
support: "https://mycompany.net/help/",
|
website: import.meta.env.Website,
|
||||||
sourcecode: "https://github.com/company/app-name"
|
support: import.meta.env.Support,
|
||||||
|
sourcecode: import.meta.env.SourceCode
|
||||||
}]
|
}]
|
||||||
|
|
||||||
// Splash
|
// Splash
|
||||||
export const SPLASH = [
|
export const SPLASH = [
|
||||||
{
|
{
|
||||||
loading: "Spinner", // "Spinner" "ProgressBar" "JumpingBalls" "GlowingBars"
|
loading: import.meta.env.LoadingIndicator,
|
||||||
background: "#232323"
|
background: import.meta.env.Background
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -17,41 +23,4 @@ export const SPLASH = [
|
||||||
/// Theming
|
/// Theming
|
||||||
export const SIDEBARTHEMING = [{
|
export const SIDEBARTHEMING = [{
|
||||||
// Edit the "Configuration for Theming" section in the `styles/index.scss`.
|
// 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",
|
|
||||||
}
|
|
||||||
]
|
|
|
@ -1,23 +1,34 @@
|
||||||
|
// ElectronJS
|
||||||
const {app, BrowserWindow, Menu} = require('electron')
|
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 glasstron = require('glasstron-clarity')
|
||||||
|
const TitlebarRespect = require('electron-titlebar-respect')
|
||||||
|
|
||||||
|
// Other dependenies
|
||||||
const isDev = require('electron-is-dev')
|
const isDev = require('electron-is-dev')
|
||||||
|
const log = require('electron-log')
|
||||||
|
const Pushy = require('pushy-electron')
|
||||||
|
|
||||||
|
// Needed for other stuff
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
let mainWindow
|
let mainWindow
|
||||||
|
|
||||||
|
// Grab .env options
|
||||||
require('dotenv').config()
|
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
|
// Use the correct icon depending on the operating system
|
||||||
if /* If macOS */ (process.platform == 'darwin') {global.AppIcon = 'public/images/icons/app/macOS.icns' }
|
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 /* If Windows */ (process.platform == 'win32') {global.AppIcon = 'public/images/icons/app/Windows.png' }
|
||||||
else /* If Linux */ {global.AppIcon = 'public/images/icons/app/Linux.png' }
|
else /* If Linux */ {global.AppIcon = 'public/images/icons/app/Linux.png' }
|
||||||
|
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
mainWindow = new glasstron.BrowserWindow({
|
mainWindow = new glasstron.BrowserWindow({
|
||||||
title: 'App Name',
|
title: process.env.Name,
|
||||||
minWidth: 400,
|
minWidth: 400,
|
||||||
minHeight: 400,
|
minHeight: 400,
|
||||||
width: 1200,
|
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>')
|
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)})}
|
if (Pushy.isRegistered()) {Pushy.subscribe('AppName').then(() => {}).catch((error) => {console.error(error)})}
|
||||||
|
|
||||||
|
@ -72,8 +83,6 @@ function createWindow () {
|
||||||
submenu: [
|
submenu: [
|
||||||
{ role: 'about' },
|
{ role: 'about' },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{ role: 'services' },
|
|
||||||
{ type: 'separator' },
|
|
||||||
{ role: 'hide' },
|
{ role: 'hide' },
|
||||||
{ role: 'hideOthers' },
|
{ role: 'hideOthers' },
|
||||||
{ role: 'unhide' },
|
{ role: 'unhide' },
|
||||||
|
@ -124,9 +133,7 @@ function createWindow () {
|
||||||
{
|
{
|
||||||
label: 'Open WebView Developer Tools',
|
label: 'Open WebView Developer Tools',
|
||||||
accelerator: 'CmdOrCtrl+Shift+W',
|
accelerator: 'CmdOrCtrl+Shift+W',
|
||||||
click: async () => {
|
click: async () => {if (isDev) {mainWindow.webContents.executeJavaScript(`document.querySelector('.active webview').openDevTools()`)}else {console.log('Not available in production mode.')}}
|
||||||
mainWindow.webContents.executeJavaScript(`document.querySelector('.active webview').openDevTools()`)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{ role: 'resetZoom' },
|
{ role: 'resetZoom' },
|
||||||
|
@ -154,13 +161,27 @@ function createWindow () {
|
||||||
{
|
{
|
||||||
role: 'help',
|
role: 'help',
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
label: 'Learn More',
|
label: 'Website',
|
||||||
click: async () => {
|
click: async () => {
|
||||||
const { shell } = require('electron')
|
const { shell } = require('electron')
|
||||||
await shell.openExternal('https://code.korbsstudio.com/KorbsStudio/nexus-polestar')
|
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(() => {
|
app.whenReady().then(() => {
|
||||||
createWindow()
|
createWindow()
|
||||||
// DNS
|
// DNS
|
||||||
// Doc: https://www.electronjs.org/docs/latest/api/app#appconfigurehostresolveroptions
|
// Docs: https://www.electronjs.org/docs/latest/api/app#appconfigurehostresolveroptions
|
||||||
app.configureHostResolver({
|
app.configureHostResolver({
|
||||||
secureDnsMode: 'secure',
|
secureDnsMode: 'secure',
|
||||||
secureDnsServers: [
|
secureDnsServers: [
|
||||||
|
|
Reference in a new issue