mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-18 22:48: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
|
||||
|
||||
module.exports = function createMenu({createWindow, updatePlugins}) {
|
||||
return [
|
||||
{
|
||||
label: 'Application',
|
||||
const osxApplicationMenu = {
|
||||
// This menu label is overrided by OSX to be the appName
|
||||
// The label is set to appName here so it matches actual behavior
|
||||
label: appName,
|
||||
submenu: [
|
||||
{
|
||||
role: 'about'
|
||||
|
|
@ -55,9 +56,10 @@ module.exports = function createMenu({createWindow, updatePlugins}) {
|
|||
role: 'quit'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Shell',
|
||||
};
|
||||
|
||||
const shellOrFileMenu = {
|
||||
label: process.platform === 'darwin' ? 'Shell' : 'File',
|
||||
submenu: [
|
||||
{
|
||||
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',
|
||||
accelerator: 'CmdOrCtrl+Shift+W'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
};
|
||||
|
||||
const editMenu = {
|
||||
label: 'Edit',
|
||||
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',
|
||||
submenu: [
|
||||
{
|
||||
|
|
@ -195,8 +216,9 @@ module.exports = function createMenu({createWindow, updatePlugins}) {
|
|||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
};
|
||||
|
||||
const pluginsMenu = {
|
||||
label: 'Plugins',
|
||||
submenu: [
|
||||
{
|
||||
|
|
@ -207,8 +229,9 @@ module.exports = function createMenu({createWindow, updatePlugins}) {
|
|||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
};
|
||||
|
||||
const windowMenu = {
|
||||
role: 'window',
|
||||
submenu: [
|
||||
{
|
||||
|
|
@ -248,8 +271,9 @@ module.exports = function createMenu({createWindow, updatePlugins}) {
|
|||
role: 'togglefullscreen'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
};
|
||||
|
||||
const helpMenu = {
|
||||
role: 'help',
|
||||
submenu: [
|
||||
{
|
||||
|
|
@ -272,11 +296,12 @@ ${process.platform} ${process.arch} ${os.release()}`;
|
|||
|
||||
shell.openExternal(`https://github.com/zeit/hyperterm/issues/new?body=${encodeURIComponent(body)}`);
|
||||
}
|
||||
},
|
||||
...(
|
||||
process.platform === 'darwin' ?
|
||||
[] :
|
||||
[
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
if (process.platform !== 'darwin') {
|
||||
helpMenu.submenu.push(
|
||||
{type: 'separator'},
|
||||
{
|
||||
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