Skip to content

Commit

Permalink
about in electron help menu (#1155)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-Arc authored Jul 29, 2024
1 parent 67be4a5 commit e500fa6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion apps/electron/main.js
Original file line number Diff line number Diff line change
@@ -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 { version } = require('./package.json');
const { getApplicationMenu } = require('./src/menu/applicationMenu.js');

const env = process.env.NODE_ENV || 'production';
Expand Down Expand Up @@ -187,7 +188,9 @@ app.whenReady().then(() => {
? electronConfig.reactAppUrl.production(port)
: electronConfig.reactAppUrl.development(port);

const template = getApplicationMenu(isMac, askToQuit, clientUrl);
const template = getApplicationMenu(isMac, askToQuit, clientUrl, `v${version}`, (path) => {
win.loadURL(`${clientUrl}/${path}`);
});
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);

Expand Down
10 changes: 9 additions & 1 deletion apps/electron/src/menu/applicationMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, urlBase) {
function getApplicationMenu(isMac, askToQuit, urlBase, version, redirectWindow) {
return [
...(isMac
? [
Expand Down Expand Up @@ -150,6 +150,14 @@ function getApplicationMenu(isMac, askToQuit, urlBase) {
{
role: 'help',
submenu: [
{
label: 'About',
click: () => redirectWindow('editor?settings=about'),
},
{
label: version,
click: () => redirectWindow('editor?settings=about'),
},
{
label: 'See on github',
click: async () => {
Expand Down

0 comments on commit e500fa6

Please sign in to comment.