mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-15 20:33:47 +00:00
temp
This commit is contained in:
+87
-91
@@ -13,8 +13,6 @@ const { electron } = require('process');
|
||||
const { nodeapp } = await import('./src/app.js');
|
||||
})();
|
||||
|
||||
require('@electron/remote/main').initialize();
|
||||
|
||||
// Load Icons
|
||||
// TODO: Icons appear pixelated
|
||||
const trayIcon = path.join(__dirname, './assets/images/logos/LOGO-512.png');
|
||||
@@ -31,69 +29,65 @@ if (!lock) {
|
||||
return;
|
||||
}
|
||||
|
||||
var win, tray;
|
||||
const { Notification } = require('electron');
|
||||
|
||||
function showNotification(text) {
|
||||
new Notification({
|
||||
title: 'ontime',
|
||||
body: text,
|
||||
}).show();
|
||||
}
|
||||
|
||||
let win;
|
||||
let tray = null;
|
||||
let loaded = false;
|
||||
|
||||
function createWindow() {
|
||||
win = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
minWidth: 500,
|
||||
minHeight: 530,
|
||||
maxWidth: 1920,
|
||||
maxHeight: 1440,
|
||||
backgroundColor: '#202020',
|
||||
icon: appIcon,
|
||||
// TODO: Make framerless
|
||||
// frame: false,
|
||||
textAreasAreResizable: false,
|
||||
enableWebSQL: false,
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, './electron/preload.js'),
|
||||
// TODO: what are recommended alternatives to node integration?
|
||||
nodeIntegration: true,
|
||||
enableRemoteModule: true,
|
||||
// enableRemoteModule: true,
|
||||
},
|
||||
});
|
||||
|
||||
win.setMenu(null);
|
||||
|
||||
// Load page served by node
|
||||
win.loadURL('http://localhost:4001/editor');
|
||||
// TODO: Make development environment and run live react instead
|
||||
// win.loadURL('http://localhost:3000/editor');
|
||||
try {
|
||||
// loaded = path.join(__dirname, '../client/build/index.html');
|
||||
// win.loadURL(`file://${loaded}`);
|
||||
// win.loadURL('http://localhost:4001/editor');
|
||||
win.loadURL(`file://${__dirname}/dist/index.html`);
|
||||
} catch (error) {
|
||||
loaded = error;
|
||||
}
|
||||
|
||||
// win.loadURL('http://localhost:4001/editor').then(() => {
|
||||
// win.webContents.setBackgroundThrottling(false);
|
||||
// });
|
||||
|
||||
// Show dev tools
|
||||
win.webContents.openDevTools({ mode: 'detach' });
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow();
|
||||
app
|
||||
.whenReady()
|
||||
.then(() => {
|
||||
createWindow();
|
||||
|
||||
// TODO: Move to separate file
|
||||
// TODO: Should move to react?
|
||||
// Define App Menu
|
||||
const appMenuTemplate = [
|
||||
{
|
||||
label: 'Help',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Getting Started',
|
||||
click: () => {
|
||||
console.log('Gonna do something here: Help > Getting Started');
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'OSC Controls',
|
||||
click: () => {
|
||||
console.log('Gonna do something here: Help > OSC Controls');
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'URL Definitions',
|
||||
click: () => {
|
||||
console.log('Gonna do something here: Help > URL Definitions');
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const appMenu = Menu.buildFromTemplate(appMenuTemplate);
|
||||
Menu.setApplicationMenu(appMenu);
|
||||
|
||||
/* ======================================
|
||||
/* ======================================
|
||||
* CONTEXT MENU CREATION ON REACT SIDE
|
||||
// Create context menu
|
||||
// const contextMenu = new Menu();
|
||||
@@ -110,59 +104,61 @@ app.whenReady().then(() => {
|
||||
* ======================================
|
||||
*/
|
||||
|
||||
// register global shortcuts
|
||||
// (available regardless of wheter app is in focus)
|
||||
// bring focus to window
|
||||
globalShortcut.register('Alt+1', () => {
|
||||
win.show();
|
||||
});
|
||||
// register global shortcuts
|
||||
// (available regardless of wheter app is in focus)
|
||||
// bring focus to window
|
||||
globalShortcut.register('Alt+1', () => {
|
||||
win.show();
|
||||
});
|
||||
|
||||
// recreate window if no others open
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
// recreate window if no others open
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
|
||||
// Hide on minimise
|
||||
win.on('minimize', function (event) {
|
||||
event.preventDefault();
|
||||
win.hide();
|
||||
});
|
||||
// Hide on minimise
|
||||
win.on('minimize', function (event) {
|
||||
event.preventDefault();
|
||||
showNotification('App running in background');
|
||||
win.hide();
|
||||
});
|
||||
|
||||
//Hide on close
|
||||
win.on('close', function (event) {
|
||||
event.preventDefault();
|
||||
win.hide();
|
||||
//Hide on close
|
||||
win.on('close', function (event) {
|
||||
event.preventDefault();
|
||||
showNotification('App running in background');
|
||||
win.hide();
|
||||
return false;
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
// create tray
|
||||
// TODO: Design better icon
|
||||
tray = new Tray(trayIcon);
|
||||
|
||||
// create tray
|
||||
// TODO: Design better icon
|
||||
tray = new Tray(trayIcon);
|
||||
|
||||
// TODO: Move to separate file
|
||||
// Define context menu
|
||||
const trayMenuTemplate = [
|
||||
{
|
||||
label: 'Show App',
|
||||
click: () => win.show(),
|
||||
},
|
||||
{
|
||||
label: 'Close',
|
||||
click: () => {
|
||||
win.destroy();
|
||||
app.quit();
|
||||
// TODO: Move to separate file
|
||||
// Define context menu
|
||||
const trayMenuTemplate = [
|
||||
{
|
||||
label: 'Show App',
|
||||
click: () => win.show(),
|
||||
},
|
||||
},
|
||||
];
|
||||
{
|
||||
label: 'Close',
|
||||
click: () => {
|
||||
win.destroy();
|
||||
app.quit();
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const trayContextMenu = Menu.buildFromTemplate(trayMenuTemplate);
|
||||
const trayContextMenu = Menu.buildFromTemplate(trayMenuTemplate);
|
||||
|
||||
tray.setContextMenu(trayContextMenu);
|
||||
tray.setToolTip('ontime running on http://localhost:4001/');
|
||||
});
|
||||
tray.setContextMenu(trayContextMenu);
|
||||
tray.setToolTip('ontime running on http://localhost:4001/');
|
||||
})
|
||||
.then(() => showNotification(loaded));
|
||||
|
||||
// unregister shortcuts before quitting
|
||||
app.once('will-quit', () => {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
"socket.io": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@electron/remote": "^1.1.0",
|
||||
"concurrently": "^6.1.0",
|
||||
"electron": "^12.0.7",
|
||||
"electron-builder": "^22.11.3",
|
||||
|
||||
+2
-3
@@ -74,8 +74,7 @@ app.get('*', (req, res) => {
|
||||
|
||||
// Implement route for errors
|
||||
app.use((err, req, res, next) => {
|
||||
console.error(err.stack);
|
||||
res.status(500).send('Something broke!');
|
||||
res.status(500).send(err.stack);
|
||||
});
|
||||
|
||||
// create HTTP server
|
||||
@@ -86,7 +85,7 @@ global.timer = new EventTimer(server, config);
|
||||
global.timer.setupWithEventList(data.events);
|
||||
|
||||
// Start server
|
||||
server.listen(port, () =>
|
||||
server.listen(port, '0.0.0.0', () =>
|
||||
console.log(`HTTP Server is listening on port ${port}`)
|
||||
);
|
||||
|
||||
|
||||
@@ -74,11 +74,6 @@
|
||||
global-agent "^2.0.2"
|
||||
global-tunnel-ng "^2.7.1"
|
||||
|
||||
"@electron/remote@^1.1.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@electron/remote/-/remote-1.1.0.tgz#167d119c7c03c7778b556fdc4f1f38a44b23f1c2"
|
||||
integrity sha512-yr8gZTkIgJYKbFqExI4QZqMSjn1kL/us9Dl46+TH1EZdhgRtsJ6HDfdsIxu0QEc6Hv+DMAXs69rgquH+8FDk4w==
|
||||
|
||||
"@electron/universal@1.0.5":
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/@electron/universal/-/universal-1.0.5.tgz#b812340e4ef21da2b3ee77b2b4d35c9b86defe37"
|
||||
|
||||
Reference in New Issue
Block a user