Add system context menu options in plugins menu

This commit is contained in:
Labhansh Agrawal 2021-01-24 22:14:04 +05:30 committed by Benjamin Staneck
parent f169c2e906
commit a78b3d9aea
2 changed files with 27 additions and 1 deletions

View file

@ -2,6 +2,7 @@ import {app, Menu, BrowserWindow} from 'electron';
import {openConfig, getConfig} from './config';
import {updatePlugins} from './plugins';
import {installCLI} from './utils/cli-install';
import * as systemContextMenu from './utils/system-context-menu';
const commands: Record<string, (focusedWindow?: BrowserWindow) => void> = {
'window:new': () => {
@ -123,6 +124,12 @@ const commands: Record<string, (focusedWindow?: BrowserWindow) => void> = {
if (process.platform !== 'darwin' && ['', true].includes(getConfig().showHamburgerMenu)) {
Menu.getApplicationMenu()!.popup({x: 25, y: 22});
}
},
'systemContextMenu:add': () => {
systemContextMenu.add();
},
'systemContextMenu:remove': () => {
systemContextMenu.remove();
}
};

View file

@ -22,7 +22,26 @@ export default (
},
{
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'
}
]
: [])
]
};
};