mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-21 15:09:10 +00:00
make application menu aware of what port should be used in link items (#890)
This commit is contained in:
@@ -3,8 +3,8 @@ module.exports = {
|
|||||||
shutdownCode: 99,
|
shutdownCode: 99,
|
||||||
},
|
},
|
||||||
reactAppUrl: {
|
reactAppUrl: {
|
||||||
development: (port = 4001) => `http://localhost:${port}/editor`,
|
development: (port = 4001) => `http://localhost:${port}`,
|
||||||
production: (port = 4001) => `http://localhost:${port}/editor`,
|
production: (port = 4001) => `http://localhost:${port}`,
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
pathToEntrypoint: '../extraResources/server/index.cjs',
|
pathToEntrypoint: '../extraResources/server/index.cjs',
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const { app, BrowserWindow, Menu, globalShortcut, Tray, dialog, ipcMain, shell, Notification } = require('electron');
|
const { app, BrowserWindow, Menu, globalShortcut, Tray, dialog, ipcMain, shell, Notification } = require('electron');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const electronConfig = require('./electron.config');
|
const electronConfig = require('./electron.config');
|
||||||
|
const { getApplicationMenu } = require('./src/menu/applicationMenu.js');
|
||||||
|
|
||||||
const env = process.env.NODE_ENV || 'production';
|
const env = process.env.NODE_ENV || 'production';
|
||||||
const isProduction = env === 'production';
|
const isProduction = env === 'production';
|
||||||
@@ -162,8 +163,12 @@ app.whenReady().then(() => {
|
|||||||
? electronConfig.reactAppUrl.production(port)
|
? electronConfig.reactAppUrl.production(port)
|
||||||
: electronConfig.reactAppUrl.development(port);
|
: electronConfig.reactAppUrl.development(port);
|
||||||
|
|
||||||
|
const template = getApplicationMenu(isMac, askToQuit, clientUrl);
|
||||||
|
const menu = Menu.buildFromTemplate(template);
|
||||||
|
Menu.setApplicationMenu(menu);
|
||||||
|
|
||||||
win
|
win
|
||||||
.loadURL(clientUrl)
|
.loadURL(`${clientUrl}/editor`)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
win.webContents.setBackgroundThrottling(false);
|
win.webContents.setBackgroundThrottling(false);
|
||||||
|
|
||||||
@@ -208,12 +213,10 @@ app.whenReady().then(() => {
|
|||||||
const trayMenuTemplate = getTrayMenu(bringToFront, askToQuit);
|
const trayMenuTemplate = getTrayMenu(bringToFront, askToQuit);
|
||||||
const trayContextMenu = Menu.buildFromTemplate(trayMenuTemplate);
|
const trayContextMenu = Menu.buildFromTemplate(trayMenuTemplate);
|
||||||
tray.setContextMenu(trayContextMenu);
|
tray.setContextMenu(trayContextMenu);
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const { getApplicationMenu } = require('./src/menu/applicationMenu.js');
|
|
||||||
const template = getApplicationMenu(isMac, askToQuit);
|
|
||||||
const menu = Menu.buildFromTemplate(template);
|
|
||||||
Menu.setApplicationMenu(menu);
|
|
||||||
|
|
||||||
// unregister shortcuts before quitting
|
// unregister shortcuts before quitting
|
||||||
app.once('will-quit', () => {
|
app.once('will-quit', () => {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const { shell } = require('electron');
|
|||||||
* @param {boolean} isMac - Whether the target platform is mac
|
* @param {boolean} isMac - Whether the target platform is mac
|
||||||
* @param {function} askToQuit - function for quitting process
|
* @param {function} askToQuit - function for quitting process
|
||||||
*/
|
*/
|
||||||
function getApplicationMenu(isMac, askToQuit) {
|
function getApplicationMenu(isMac, askToQuit, urlBase) {
|
||||||
return [
|
return [
|
||||||
...(isMac
|
...(isMac
|
||||||
? [
|
? [
|
||||||
@@ -63,68 +63,68 @@ function getApplicationMenu(isMac, askToQuit) {
|
|||||||
label: 'Timer',
|
label: 'Timer',
|
||||||
accelerator: 'CmdOrCtrl+V',
|
accelerator: 'CmdOrCtrl+V',
|
||||||
click: async () => {
|
click: async () => {
|
||||||
await shell.openExternal('http://localhost:4001/timer');
|
await shell.openExternal(`${urlBase}/timer`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Clock',
|
label: 'Clock',
|
||||||
click: async () => {
|
click: async () => {
|
||||||
await shell.openExternal('http://localhost:4001/clock');
|
await shell.openExternal(`${urlBase}/clock`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Minimal Timer',
|
label: 'Minimal Timer',
|
||||||
click: async () => {
|
click: async () => {
|
||||||
await shell.openExternal('http://localhost:4001/minimal');
|
await shell.openExternal(`${urlBase}/minimal`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Backstage',
|
label: 'Backstage',
|
||||||
click: async () => {
|
click: async () => {
|
||||||
await shell.openExternal('http://localhost:4001/backstage');
|
await shell.openExternal(`${urlBase}/backstage`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Public',
|
label: 'Public',
|
||||||
click: async () => {
|
click: async () => {
|
||||||
await shell.openExternal('http://localhost:4001/public');
|
await shell.openExternal(`${urlBase}/public`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Lower Thirds',
|
label: 'Lower Thirds',
|
||||||
click: async () => {
|
click: async () => {
|
||||||
await shell.openExternal('http://localhost:4001/lower');
|
await shell.openExternal(`${urlBase}/lower`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Studio Clock',
|
label: 'Studio Clock',
|
||||||
click: async () => {
|
click: async () => {
|
||||||
await shell.openExternal('http://localhost:4001/studio');
|
await shell.openExternal(`${urlBase}/studio`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Countdown',
|
label: 'Countdown',
|
||||||
click: async () => {
|
click: async () => {
|
||||||
await shell.openExternal('http://localhost:4001/countdown');
|
await shell.openExternal(`${urlBase}/countdown`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
{
|
{
|
||||||
label: 'Editor',
|
label: 'Editor',
|
||||||
click: async () => {
|
click: async () => {
|
||||||
await shell.openExternal('http://localhost:4001/editor');
|
await shell.openExternal(`${urlBase}/editor`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Cuesheet',
|
label: 'Cuesheet',
|
||||||
click: async () => {
|
click: async () => {
|
||||||
await shell.openExternal('http://localhost:4001/cuesheet');
|
await shell.openExternal(`${urlBase}/cuesheet`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Operator',
|
label: 'Operator',
|
||||||
click: async () => {
|
click: async () => {
|
||||||
await shell.openExternal('http://localhost:4001/operator');
|
await shell.openExternal(`${urlBase}/operator`);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user