2020-10-09 20:42:44 +00:00
|
|
|
import { app, Menu } from 'electron/main';
|
2020-07-13 16:58:49 +00:00
|
|
|
import { shell } from 'electron/common';
|
2019-01-10 19:54:34 +00:00
|
|
|
|
2019-01-10 13:32:03 +00:00
|
|
|
const isMac = process.platform === 'darwin';
|
|
|
|
|
2021-06-03 05:59:56 +00:00
|
|
|
let applicationMenuWasSet = false;
|
|
|
|
|
|
|
|
export const setApplicationMenuWasSet = () => {
|
|
|
|
applicationMenuWasSet = true;
|
|
|
|
};
|
|
|
|
|
2019-02-12 14:22:33 +00:00
|
|
|
export const setDefaultApplicationMenu = () => {
|
2021-06-03 05:59:56 +00:00
|
|
|
if (applicationMenuWasSet) return;
|
2018-09-21 05:24:42 +00:00
|
|
|
|
2019-02-12 14:22:33 +00:00
|
|
|
const helpMenu: Electron.MenuItemConstructorOptions = {
|
2019-01-10 13:32:03 +00:00
|
|
|
role: 'help',
|
2020-10-09 20:42:44 +00:00
|
|
|
submenu: app.isPackaged ? [] : [
|
2019-01-10 13:32:03 +00:00
|
|
|
{
|
|
|
|
label: 'Learn More',
|
2019-05-03 20:53:45 +00:00
|
|
|
click: async () => {
|
|
|
|
await shell.openExternal('https://electronjs.org');
|
2018-09-21 05:24:42 +00:00
|
|
|
}
|
2019-01-10 13:32:03 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Documentation',
|
2019-05-03 20:53:45 +00:00
|
|
|
click: async () => {
|
|
|
|
const version = process.versions.electron;
|
|
|
|
await shell.openExternal(`https://github.com/electron/electron/tree/v${version}/docs#readme`);
|
2018-09-21 05:24:42 +00:00
|
|
|
}
|
2019-01-10 13:32:03 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Community Discussions',
|
2019-05-03 20:53:45 +00:00
|
|
|
click: async () => {
|
2022-07-05 15:55:15 +00:00
|
|
|
await shell.openExternal('https://discord.gg/electronjs');
|
2018-09-21 05:24:42 +00:00
|
|
|
}
|
2019-01-10 13:32:03 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Search Issues',
|
2019-05-03 20:53:45 +00:00
|
|
|
click: async () => {
|
|
|
|
await shell.openExternal('https://github.com/electron/electron/issues');
|
2018-09-21 05:24:42 +00:00
|
|
|
}
|
2019-01-10 13:32:03 +00:00
|
|
|
}
|
|
|
|
]
|
2018-09-21 05:24:42 +00:00
|
|
|
};
|
|
|
|
|
2019-02-12 14:22:33 +00:00
|
|
|
const macAppMenu: Electron.MenuItemConstructorOptions = { role: 'appMenu' };
|
|
|
|
const template: Electron.MenuItemConstructorOptions[] = [
|
|
|
|
...(isMac ? [macAppMenu] : []),
|
2019-01-10 13:32:03 +00:00
|
|
|
{ role: 'fileMenu' },
|
|
|
|
{ role: 'editMenu' },
|
|
|
|
{ role: 'viewMenu' },
|
|
|
|
{ role: 'windowMenu' },
|
|
|
|
helpMenu
|
|
|
|
];
|
|
|
|
|
2018-09-21 05:24:42 +00:00
|
|
|
const menu = Menu.buildFromTemplate(template);
|
|
|
|
Menu.setApplicationMenu(menu);
|
|
|
|
};
|