hyper/app/menus/menus/tools.ts

50 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-06-26 01:29:50 -08:00
import type {BrowserWindow, MenuItemConstructorOptions} from 'electron';
2019-12-20 08:55:03 -09:00
2023-07-25 08:11:02 -08:00
const toolsMenu = (
2019-12-20 08:55:03 -09:00
commands: Record<string, string>,
execCommand: (command: string, focusedWindow?: BrowserWindow) => void
): MenuItemConstructorOptions => {
return {
2021-01-22 00:35:26 -09:00
label: 'Tools',
submenu: [
{
2021-01-22 00:35:26 -09:00
label: 'Update plugins',
accelerator: commands['plugins:update'],
click() {
execCommand('plugins:update');
}
},
{
label: 'Install Hyper CLI command in PATH',
click() {
execCommand('cli:install');
}
},
{
type: 'separator'
},
...(process.platform === 'win32'
? <MenuItemConstructorOptions[]>[
{
label: 'Add Hyper to system context menu',
click() {
execCommand('systemContextMenu:add');
}
},
{
label: 'Remove Hyper from system context menu',
click() {
execCommand('systemContextMenu:remove');
}
},
{
type: 'separator'
}
]
: [])
]
};
};
2023-07-25 08:11:02 -08:00
export default toolsMenu;