mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-17 05:58:41 -09:00
fix: on Linux/Win, hide OSX specific menu items and change 'Shell' to 'File' (#736)
Based on this document: https://github.com/electron/electron/blob/master/docs/api/menu.md#user-content-notes-on-os-x-application-menu
This commit is contained in:
parent
a27f5556fd
commit
6959667589
1 changed files with 299 additions and 265 deletions
84
app/menu.js
84
app/menu.js
|
|
@ -8,9 +8,10 @@ const appName = app.getName();
|
||||||
// https://github.com/sindresorhus/anatine/blob/master/menu.js
|
// https://github.com/sindresorhus/anatine/blob/master/menu.js
|
||||||
|
|
||||||
module.exports = function createMenu({createWindow, updatePlugins}) {
|
module.exports = function createMenu({createWindow, updatePlugins}) {
|
||||||
return [
|
const osxApplicationMenu = {
|
||||||
{
|
// This menu label is overrided by OSX to be the appName
|
||||||
label: 'Application',
|
// The label is set to appName here so it matches actual behavior
|
||||||
|
label: appName,
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
role: 'about'
|
role: 'about'
|
||||||
|
|
@ -55,9 +56,10 @@ module.exports = function createMenu({createWindow, updatePlugins}) {
|
||||||
role: 'quit'
|
role: 'quit'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
};
|
||||||
{
|
|
||||||
label: 'Shell',
|
const shellOrFileMenu = {
|
||||||
|
label: process.platform === 'darwin' ? 'Shell' : 'File',
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
label: 'New Window',
|
label: 'New Window',
|
||||||
|
|
@ -90,13 +92,14 @@ module.exports = function createMenu({createWindow, updatePlugins}) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Close Terminal Window',
|
label: process.platform === 'darwin' ? 'Close Terminal Window' : 'Quit',
|
||||||
role: 'close',
|
role: 'close',
|
||||||
accelerator: 'CmdOrCtrl+Shift+W'
|
accelerator: 'CmdOrCtrl+Shift+W'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
};
|
||||||
{
|
|
||||||
|
const editMenu = {
|
||||||
label: 'Edit',
|
label: 'Edit',
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
|
|
@ -133,8 +136,26 @@ module.exports = function createMenu({createWindow, updatePlugins}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
};
|
||||||
|
|
||||||
|
if (process.platform !== 'darwin') {
|
||||||
|
editMenu.submenu.push(
|
||||||
|
{type: 'separator'},
|
||||||
{
|
{
|
||||||
|
label: 'Preferences...',
|
||||||
|
accelerator: 'Cmd+,',
|
||||||
|
click(item, focusedWindow) {
|
||||||
|
if (focusedWindow) {
|
||||||
|
focusedWindow.rpc.emit('preferences');
|
||||||
|
} else {
|
||||||
|
createWindow(win => win.rpc.emit('preferences'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const viewMenu = {
|
||||||
label: 'View',
|
label: 'View',
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
|
|
@ -195,8 +216,9 @@ module.exports = function createMenu({createWindow, updatePlugins}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
};
|
||||||
{
|
|
||||||
|
const pluginsMenu = {
|
||||||
label: 'Plugins',
|
label: 'Plugins',
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
|
|
@ -207,8 +229,9 @@ module.exports = function createMenu({createWindow, updatePlugins}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
};
|
||||||
{
|
|
||||||
|
const windowMenu = {
|
||||||
role: 'window',
|
role: 'window',
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
|
|
@ -248,8 +271,9 @@ module.exports = function createMenu({createWindow, updatePlugins}) {
|
||||||
role: 'togglefullscreen'
|
role: 'togglefullscreen'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
};
|
||||||
{
|
|
||||||
|
const helpMenu = {
|
||||||
role: 'help',
|
role: 'help',
|
||||||
submenu: [
|
submenu: [
|
||||||
{
|
{
|
||||||
|
|
@ -272,11 +296,12 @@ ${process.platform} ${process.arch} ${os.release()}`;
|
||||||
|
|
||||||
shell.openExternal(`https://github.com/zeit/hyperterm/issues/new?body=${encodeURIComponent(body)}`);
|
shell.openExternal(`https://github.com/zeit/hyperterm/issues/new?body=${encodeURIComponent(body)}`);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
...(
|
]
|
||||||
process.platform === 'darwin' ?
|
};
|
||||||
[] :
|
|
||||||
[
|
if (process.platform !== 'darwin') {
|
||||||
|
helpMenu.submenu.push(
|
||||||
{type: 'separator'},
|
{type: 'separator'},
|
||||||
{
|
{
|
||||||
role: 'about',
|
role: 'about',
|
||||||
|
|
@ -290,9 +315,18 @@ ${process.platform} ${process.arch} ${os.release()}`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
);
|
||||||
)
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
];
|
|
||||||
|
const menu = [].concat(
|
||||||
|
process.platform === 'darwin' ? osxApplicationMenu : [],
|
||||||
|
shellOrFileMenu,
|
||||||
|
editMenu,
|
||||||
|
viewMenu,
|
||||||
|
pluginsMenu,
|
||||||
|
windowMenu,
|
||||||
|
helpMenu
|
||||||
|
);
|
||||||
|
|
||||||
|
return menu;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue