This commit is contained in:
YeonV 2022-09-24 00:53:09 +02:00
parent 366eebd669
commit 723cc9357d
13 changed files with 222 additions and 174 deletions

View File

@ -16,7 +16,7 @@ REQUIRED_PYTHON_STRING = ">={}.{}.{}".format(
MAJOR_VERSION = 2
MINOR_VERSION = 0
MICRO_VERSION = 50
MICRO_VERSION = 51
POST = 0
DEV = 0
PROJECT_VERSION = "{}.{}.{}".format(

View File

@ -1,7 +1,7 @@
{
"files": {
"main.css": "/static/css/main.6da0b526.css",
"main.js": "/static/js/main.cde7efcd.js",
"main.css": "/static/css/main.19f575e8.css",
"main.js": "/static/js/main.b557427d.js",
"static/js/787.15424a8e.chunk.js": "/static/js/787.15424a8e.chunk.js",
"static/media/materialdesignicons-webfont.woff": "/static/media/materialdesignicons-webfont.059ea00c378aeafc39fc.woff",
"static/media/transitions.gif": "/static/media/transitions.53b6d6f458b421f00872.gif",
@ -11,12 +11,12 @@
"static/media/ring.png": "/static/media/ring.1faea45b576b5380bde1.png",
"static/media/blademod.svg": "/static/media/blademod.f939f478785a84b3edcc820eef654556.svg",
"index.html": "/index.html",
"main.6da0b526.css.map": "/static/css/main.6da0b526.css.map",
"main.cde7efcd.js.map": "/static/js/main.cde7efcd.js.map",
"main.19f575e8.css.map": "/static/css/main.19f575e8.css.map",
"main.b557427d.js.map": "/static/js/main.b557427d.js.map",
"787.15424a8e.chunk.js.map": "/static/js/787.15424a8e.chunk.js.map"
},
"entrypoints": [
"static/css/main.6da0b526.css",
"static/js/main.cde7efcd.js"
"static/css/main.19f575e8.css",
"static/js/main.b557427d.js"
]
}

View File

@ -42,8 +42,8 @@ function createWindow(args = {}) {
require('@electron/remote/main').initialize();
// Create the browser window.
win = new BrowserWindow({
width: 480,
height: 768,
width: 1024,
height: 1024,
autoHideMenuBar: true,
titleBarStyle: process.platform === 'darwin' ? 'default' : 'hidden',
titleBarOverlay:
@ -96,182 +96,230 @@ let contextMenu = null;
let wind;
let willQuitApp = false
if (process.defaultApp) {
if (process.argv.length >= 2) {
app.setAsDefaultProtocolClient('ledfx', process.execPath, [path.resolve(process.argv[1])])
}
} else {
app.setAsDefaultProtocolClient('ledfx')
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.whenReady().then(async () => {
nativeTheme.themeSource = 'dark';
const thePath = process.env.PORTABLE_EXECUTABLE_DIR || path.resolve('.');
const integratedCore = (process.platform === 'darwin')
? fs.existsSync(path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx_core.app'))
: fs.existsSync(path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx-notray.exe'))
const gotTheLock = app.requestSingleInstanceLock()
const currentDir = fs.readdirSync(thePath)
console.log(currentDir)
const ready = () => (
app.whenReady().then(async () => {
nativeTheme.themeSource = 'dark';
const thePath = process.env.PORTABLE_EXECUTABLE_DIR || path.resolve('.');
if (integratedCore) {
if (process.platform === 'darwin') {
subpy = require('child_process').spawn(`${path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx_core.app/Contents/MacOS/LedFx_v2')}`, []);
} else {
subpy = require('child_process').spawn(`${path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx-notray.exe')}`, ['-p', '8888']);
}
}
const integratedCore = (process.platform === 'darwin')
? fs.existsSync(path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx_core.app'))
: fs.existsSync(path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx-notray.exe'))
wind = integratedCore
? createWindow({ additionalArguments: ['integratedCore'] })
: createWindow();
const currentDir = fs.readdirSync(thePath)
console.log(currentDir)
require('@electron/remote/main').enable(wind.webContents);
if (isDev) {
await installExtension([REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS], {
loadExtensionOptions: { allowFileAccess: true },
forceDownload: false,
})
.then((name) => console.log(`Added Extension: ${name}`))
.catch((error) => console.log(`An error occurred: , ${error}`));
}
const icon = path.join(__dirname, 'icon_16x16a.png');
tray = new Tray(icon);
if (integratedCore) {
contextMenu = Menu.buildFromTemplate([
{ label: 'Show', click: () => {
if (process.platform === 'darwin') app.dock.show()
wind.show()
}},
{ label: 'Minimize', click: () => wind.minimize() },
{ label: 'Minimize to tray', click: () => {
if (process.platform === 'darwin') app.dock.hide()
wind.hide()
}},
// { label: 'Test Notifiation', click: () => showNotification() },
{ label: 'seperator', type: 'separator' },
{ label: 'Dev', click: () => wind.webContents.openDevTools() },
{ label: 'seperator', type: 'separator' },
{
label: 'Start core',
click: () => (process.platform === 'darwin')
? subpy = require('child_process').spawn(`${path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx_core.app/Contents/MacOS/LedFx_v2')}`, [])
: subpy = require('child_process').spawn(`${path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx-notray.exe')}`, ['-p', '8888'])
},
{
label: 'Stop core',
click: () => wind.webContents.send('fromMain', 'shutdown'),
},
// { label: 'Download core', click: () => download(wind, `https://github.com/YeonV/LedFx-Frontend-v2/releases/latest/download/LedFx_core-${app.getVersion().split('-')[1]}--win-portable.exe`, { directory: thePath, overwrite: true }).then((f) => { app.relaunch(); app.exit() }) },
{
label: 'Restart Client',
click: () => {
app.relaunch();
app.exit();
},
},
{ label: 'Open folder', click: () => shell.openPath(thePath) },
{ label: 'seperator', type: 'separator' },
{ label: 'Exit', click: () => app.quit() },
]);
} else {
contextMenu = Menu.buildFromTemplate([
{ label: 'Show', click: () => {
if (process.platform === 'darwin') app.dock.show()
wind.show()
}},
{ label: 'Minimize', click: () => wind.minimize() },
{ label: 'Minimize to tray', click: () => {
if (process.platform === 'darwin') app.dock.hide()
wind.hide()
}},
// { label: 'Test Notifiation', click: () => showNotification() },
{ label: 'seperator', type: 'separator' },
{ label: 'Dev', click: () => wind.webContents.openDevTools() },
{ label: 'seperator', type: 'separator' },
{
label: 'Stop core',
click: () => wind.webContents.send('fromMain', 'shutdown'),
},
// { label: 'Download core', click: () => download(wind, `https://github.com/YeonV/LedFx-Frontend-v2/releases/latest/download/LedFx_core-${app.getVersion().split('-')[1]}--win-portable.exe`, { directory: thePath, overwrite: true, onProgress: (obj)=>{wind.webContents.send('fromMain', ['download-progress', obj])} }).then((f) => { wind.webContents.send('fromMain', 'clear-frontend'); app.relaunch(); app.exit() })},
{
label: 'Restart Client',
click: () => {
app.relaunch();
app.exit();
},
},
{ label: 'Open folder', click: () => shell.openPath(thePath) },
{ label: 'seperator', type: 'separator' },
{ label: 'Exit', click: () => app.quit() },
]);
}
tray.setToolTip(`LedFx Client${isDev ? ' DEV' : ''}`);
tray.setContextMenu(contextMenu);
tray.setIgnoreDoubleClickEvents(true);
tray.on('click', () => wind.show());
ipcMain.on('toMain', (event, parameters) => {
console.log(parameters);
if (parameters === 'get-platform') {
wind.webContents.send('fromMain', ['platform', process.platform]);
return;
}
if (parameters === 'start-core') {
if (integratedCore) {
if (process.platform === 'darwin') {
wind.webContents.send('fromMain', ['currentdir', integratedCore, fs.existsSync(path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx_core.app'))]);
subpy = require('child_process').spawn(`${path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx_core.app/Contents/MacOS/LedFx_v2')}`, []);
} else {
wind.webContents.send('fromMain', ['currentdir', integratedCore, fs.existsSync(path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx-notray.exe'))]);
subpy = require('child_process').spawn(`${path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx-notray.exe')}`, []);
}
if (integratedCore) {
if (process.platform === 'darwin') {
subpy = require('child_process').spawn(`${path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx_core.app/Contents/MacOS/LedFx_v2')}`, []);
} else {
subpy = require('child_process').spawn(`${path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx-notray.exe')}`, ['-p', '8888']);
}
return;
}
wind = integratedCore
? createWindow({ additionalArguments: ['integratedCore'] })
: createWindow();
require('@electron/remote/main').enable(wind.webContents);
if (isDev) {
await installExtension([REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS], {
loadExtensionOptions: { allowFileAccess: true },
forceDownload: false,
})
.then((name) => console.log(`Added Extension: ${name}`))
.catch((error) => console.log(`An error occurred: , ${error}`));
}
if (parameters === 'open-config') {
console.log('Open Config');
wind.webContents.send('fromMain', ['currentdir', path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources')]);
shell.showItemInFolder(
path.join(app.getPath('appData'), '/.ledfx/config.json')
);
return;
}
if (parameters === 'restart-client') {
app.relaunch();
app.exit();
return;
}
if (parameters === 'download-core') {
download(
wind,
`https://github.com/YeonV/LedFx-Frontend-v2/releases/latest/download/LedFx_core-${
app.getVersion().split('-')[1]
}--win-portable.exe`,
const icon = path.join(__dirname, 'icon_16x16a.png');
tray = new Tray(icon);
if (integratedCore) {
contextMenu = Menu.buildFromTemplate([
{ label: 'Show', click: () => {
if (process.platform === 'darwin') app.dock.show()
wind.show()
}},
{ label: 'Minimize', click: () => wind.minimize() },
{ label: 'Minimize to tray', click: () => {
if (process.platform === 'darwin') app.dock.hide()
wind.hide()
}},
// { label: 'Test Notifiation', click: () => showNotification() },
{ label: 'seperator', type: 'separator' },
{ label: 'Dev', click: () => wind.webContents.openDevTools() },
{ label: 'seperator', type: 'separator' },
{
directory: thePath,
overwrite: true,
onProgress: (obj) => {
wind.webContents.send('fromMain', ['download-progress', obj]);
label: 'Start core',
click: () => (process.platform === 'darwin')
? subpy = require('child_process').spawn(`${path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx_core.app/Contents/MacOS/LedFx_v2')}`, [])
: subpy = require('child_process').spawn(`${path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx-notray.exe')}`, ['-p', '8888'])
},
{
label: 'Stop core',
click: () => wind.webContents.send('fromMain', 'shutdown'),
},
// { label: 'Download core', click: () => download(wind, `https://github.com/YeonV/LedFx-Frontend-v2/releases/latest/download/LedFx_core-${app.getVersion().split('-')[1]}--win-portable.exe`, { directory: thePath, overwrite: true }).then((f) => { app.relaunch(); app.exit() }) },
{
label: 'Restart Client',
click: () => {
app.relaunch();
app.exit();
},
},
{ label: 'Open folder', click: () => shell.openPath(thePath) },
{ label: 'seperator', type: 'separator' },
{ label: 'Exit', click: () => app.quit() },
]);
} else {
contextMenu = Menu.buildFromTemplate([
{ label: 'Show', click: () => {
if (process.platform === 'darwin') app.dock.show()
wind.show()
}},
{ label: 'Minimize', click: () => wind.minimize() },
{ label: 'Minimize to tray', click: () => {
if (process.platform === 'darwin') app.dock.hide()
wind.hide()
}},
// { label: 'Test Notifiation', click: () => showNotification() },
{ label: 'seperator', type: 'separator' },
{ label: 'Dev', click: () => wind.webContents.openDevTools() },
{ label: 'seperator', type: 'separator' },
{
label: 'Stop core',
click: () => wind.webContents.send('fromMain', 'shutdown'),
},
// { label: 'Download core', click: () => download(wind, `https://github.com/YeonV/LedFx-Frontend-v2/releases/latest/download/LedFx_core-${app.getVersion().split('-')[1]}--win-portable.exe`, { directory: thePath, overwrite: true, onProgress: (obj)=>{wind.webContents.send('fromMain', ['download-progress', obj])} }).then((f) => { wind.webContents.send('fromMain', 'clear-frontend'); app.relaunch(); app.exit() })},
{
label: 'Restart Client',
click: () => {
app.relaunch();
app.exit();
},
},
{ label: 'Open folder', click: () => shell.openPath(thePath) },
{ label: 'seperator', type: 'separator' },
{ label: 'Exit', click: () => app.quit() },
]);
}
tray.setToolTip(`LedFx Client${isDev ? ' DEV' : ''}`);
tray.setContextMenu(contextMenu);
tray.setIgnoreDoubleClickEvents(true);
tray.on('click', () => wind.show());
ipcMain.on('toMain', (event, parameters) => {
console.log(parameters);
if (parameters === 'get-platform') {
wind.webContents.send('fromMain', ['platform', process.platform]);
return;
}
if (parameters === 'start-core') {
if (integratedCore) {
if (process.platform === 'darwin') {
wind.webContents.send('fromMain', ['currentdir', integratedCore, fs.existsSync(path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx_core.app'))]);
subpy = require('child_process').spawn(`${path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx_core.app/Contents/MacOS/LedFx_v2')}`, []);
} else {
wind.webContents.send('fromMain', ['currentdir', integratedCore, fs.existsSync(path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx-notray.exe'))]);
subpy = require('child_process').spawn(`${path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources','LedFx-notray.exe')}`, []);
}
}
).then(() => {
wind.webContents.send('fromMain', 'clear-frontend');
return;
}
if (parameters === 'open-config') {
console.log('Open Config');
wind.webContents.send('fromMain', ['currentdir', path.join(path.dirname(__dirname), isDev ? 'extraResources' : '../extraResources')]);
shell.showItemInFolder(
path.join(app.getPath('appData'), '/.ledfx/config.json')
);
return;
}
if (parameters === 'restart-client') {
app.relaunch();
app.exit();
});
}
});
return;
}
if (parameters === 'download-core') {
download(
wind,
`https://github.com/YeonV/LedFx-Frontend-v2/releases/latest/download/LedFx_core-${
app.getVersion().split('-')[1]
}--win-portable.exe`,
{
directory: thePath,
overwrite: true,
onProgress: (obj) => {
wind.webContents.send('fromMain', ['download-progress', obj]);
},
}
).then(() => {
wind.webContents.send('fromMain', 'clear-frontend');
app.relaunch();
app.exit();
});
}
});
wind.on('close', function(e){
if (subpy !== null) {
subpy.kill('SIGINT');
}
wind.on('close', function(e){
if (subpy !== null) {
subpy.kill('SIGINT');
wind.webContents.send('fromMain', 'shutdown');
}
})
})
});
)
if (process.platform === 'win32') {
if (!gotTheLock) {
app.quit()
} else {
app.on('second-instance', (event, commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (wind) {
if (wind.isMinimized()) wind.restore()
wind.focus()
wind.webContents.send('fromMain', ['protocol', JSON.stringify({event, commandLine, workingDirectory})]);
}
})
ready()
// Handle the protocol. In this case, we choose to show an Error Box.
app.on('open-url', (event, url) => {
event.preventDefault()
console.log(event, url)
})
}
} else {
ready()
// Handle the protocol. In this case, we choose to show an Error Box.
app.on('open-url', (event, url) => {
event.preventDefault()
console.log(event, url)
})
}
app.on('window-all-closed', () => {
app.quit();
if (subpy !== null) {
subpy.kill('SIGINT');
}
app.quit();
});
app.on('before-quit', () => {

View File

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="description" content="LedFx Client - by Blade"/><link rel="apple-touch-icon" sizes="57x57" href="/favicon/apple-icon-57x57.png"><link rel="apple-touch-icon" sizes="60x60" href="/favicon/apple-icon-60x60.png"><link rel="apple-touch-icon" sizes="72x72" href="/favicon/apple-icon-72x72.png"><link rel="apple-touch-icon" sizes="76x76" href="/favicon/apple-icon-76x76.png"><link rel="apple-touch-icon" sizes="114x114" href="/favicon/apple-icon-114x114.png"><link rel="apple-touch-icon" sizes="120x120" href="/favicon/apple-icon-120x120.png"><link rel="apple-touch-icon" sizes="144x144" href="/favicon/apple-icon-144x144.png"><link rel="apple-touch-icon" sizes="152x152" href="/favicon/apple-icon-152x152.png"><link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-icon-180x180.png"><link rel="icon" type="image/png" sizes="192x192" href="/favicon/android-icon-192x192.png"><link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png"><link rel="icon" type="image/png" sizes="96x96" href="/favicon/favicon-96x96.png"><link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png"><meta name="msapplication-TileColor" content="#333333"><meta name="msapplication-TileImage" content="/favicon/ms-icon-144x144.png"><meta name="theme-color" content="#333333"><meta name="background-color" content="#020202"><link rel="manifest" href="/manifest.json"/><title>LedFx</title><script defer="defer" src="/static/js/main.cde7efcd.js"></script><link href="/static/css/main.6da0b526.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><script type="application/javascript">"serviceWorker"in navigator&&window.addEventListener("load",(function(){navigator.serviceWorker.register("serviceWorker.js",{scope:"."}).then((function(e){console.debug("ServiceWorker registration successful with scope: ",e.scope)}),(function(e){console.debug("ServiceWorker registration failed: ",e)}))}))</script><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="description" content="LedFx Client - by Blade"/><link rel="apple-touch-icon" sizes="57x57" href="/favicon/apple-icon-57x57.png"><link rel="apple-touch-icon" sizes="60x60" href="/favicon/apple-icon-60x60.png"><link rel="apple-touch-icon" sizes="72x72" href="/favicon/apple-icon-72x72.png"><link rel="apple-touch-icon" sizes="76x76" href="/favicon/apple-icon-76x76.png"><link rel="apple-touch-icon" sizes="114x114" href="/favicon/apple-icon-114x114.png"><link rel="apple-touch-icon" sizes="120x120" href="/favicon/apple-icon-120x120.png"><link rel="apple-touch-icon" sizes="144x144" href="/favicon/apple-icon-144x144.png"><link rel="apple-touch-icon" sizes="152x152" href="/favicon/apple-icon-152x152.png"><link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-icon-180x180.png"><link rel="icon" type="image/png" sizes="192x192" href="/favicon/android-icon-192x192.png"><link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png"><link rel="icon" type="image/png" sizes="96x96" href="/favicon/favicon-96x96.png"><link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png"><meta name="msapplication-TileColor" content="#333333"><meta name="msapplication-TileImage" content="/favicon/ms-icon-144x144.png"><meta name="theme-color" content="#333333"><meta name="background-color" content="#020202"><link rel="manifest" href="/manifest.json"/><title>LedFx</title><script defer="defer" src="/static/js/main.b557427d.js"></script><link href="/static/css/main.19f575e8.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><script type="application/javascript">"serviceWorker"in navigator&&window.addEventListener("load",(function(){navigator.serviceWorker.register("serviceWorker.js",{scope:"."}).then((function(e){console.debug("ServiceWorker registration successful with scope: ",e.scope)}),(function(e){console.debug("ServiceWorker registration failed: ",e)}))}))</script><div id="root"></div></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long