make application menu aware of what port should be used in link items (#890)

This commit is contained in:
2024-04-16 14:20:41 -05:00
committed by GitHub
parent 70c93a69fe
commit a8e9962eed
3 changed files with 22 additions and 19 deletions
+2 -2
View File
@@ -3,8 +3,8 @@ module.exports = {
shutdownCode: 99,
},
reactAppUrl: {
development: (port = 4001) => `http://localhost:${port}/editor`,
production: (port = 4001) => `http://localhost:${port}/editor`,
development: (port = 4001) => `http://localhost:${port}`,
production: (port = 4001) => `http://localhost:${port}`,
},
server: {
pathToEntrypoint: '../extraResources/server/index.cjs',
+8 -5
View File
@@ -1,6 +1,7 @@
const { app, BrowserWindow, Menu, globalShortcut, Tray, dialog, ipcMain, shell, Notification } = require('electron');
const path = require('path');
const electronConfig = require('./electron.config');
const { getApplicationMenu } = require('./src/menu/applicationMenu.js');
const env = process.env.NODE_ENV || 'production';
const isProduction = env === 'production';
@@ -162,8 +163,12 @@ app.whenReady().then(() => {
? electronConfig.reactAppUrl.production(port)
: electronConfig.reactAppUrl.development(port);
const template = getApplicationMenu(isMac, askToQuit, clientUrl);
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
win
.loadURL(clientUrl)
.loadURL(`${clientUrl}/editor`)
.then(() => {
win.webContents.setBackgroundThrottling(false);
@@ -208,12 +213,10 @@ app.whenReady().then(() => {
const trayMenuTemplate = getTrayMenu(bringToFront, askToQuit);
const trayContextMenu = Menu.buildFromTemplate(trayMenuTemplate);
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
app.once('will-quit', () => {
+12 -12
View File
@@ -4,7 +4,7 @@ const { shell } = require('electron');
* @param {boolean} isMac - Whether the target platform is mac
* @param {function} askToQuit - function for quitting process
*/
function getApplicationMenu(isMac, askToQuit) {
function getApplicationMenu(isMac, askToQuit, urlBase) {
return [
...(isMac
? [
@@ -63,68 +63,68 @@ function getApplicationMenu(isMac, askToQuit) {
label: 'Timer',
accelerator: 'CmdOrCtrl+V',
click: async () => {
await shell.openExternal('http://localhost:4001/timer');
await shell.openExternal(`${urlBase}/timer`);
},
},
{
label: 'Clock',
click: async () => {
await shell.openExternal('http://localhost:4001/clock');
await shell.openExternal(`${urlBase}/clock`);
},
},
{
label: 'Minimal Timer',
click: async () => {
await shell.openExternal('http://localhost:4001/minimal');
await shell.openExternal(`${urlBase}/minimal`);
},
},
{
label: 'Backstage',
click: async () => {
await shell.openExternal('http://localhost:4001/backstage');
await shell.openExternal(`${urlBase}/backstage`);
},
},
{
label: 'Public',
click: async () => {
await shell.openExternal('http://localhost:4001/public');
await shell.openExternal(`${urlBase}/public`);
},
},
{
label: 'Lower Thirds',
click: async () => {
await shell.openExternal('http://localhost:4001/lower');
await shell.openExternal(`${urlBase}/lower`);
},
},
{
label: 'Studio Clock',
click: async () => {
await shell.openExternal('http://localhost:4001/studio');
await shell.openExternal(`${urlBase}/studio`);
},
},
{
label: 'Countdown',
click: async () => {
await shell.openExternal('http://localhost:4001/countdown');
await shell.openExternal(`${urlBase}/countdown`);
},
},
{ type: 'separator' },
{
label: 'Editor',
click: async () => {
await shell.openExternal('http://localhost:4001/editor');
await shell.openExternal(`${urlBase}/editor`);
},
},
{
label: 'Cuesheet',
click: async () => {
await shell.openExternal('http://localhost:4001/cuesheet');
await shell.openExternal(`${urlBase}/cuesheet`);
},
},
{
label: 'Operator',
click: async () => {
await shell.openExternal('http://localhost:4001/operator');
await shell.openExternal(`${urlBase}/operator`);
},
},
],