This commit is contained in:
Kevin Sawicki 2016-06-20 17:03:48 -07:00
Родитель f45e6c6c38
Коммит a16d907684
1 изменённых файлов: 10 добавлений и 3 удалений

Просмотреть файл

@ -15,7 +15,8 @@ rolesMap = {
selectall: 'selectAll',
minimize: 'minimize',
close: 'close',
delete: 'delete'
delete: 'delete',
quit: 'quit'
}
// Maps methods that should be called directly on the BrowserWindow instance
@ -24,12 +25,16 @@ methodInBrowserWindow = {
close: true
}
const methodInApp = {
quit: true
}
MenuItem = (function () {
MenuItem.types = ['normal', 'separator', 'submenu', 'checkbox', 'radio']
function MenuItem (options) {
var click, ref
const Menu = require('electron').Menu
const {app, Menu} = require('electron')
click = options.click
this.selector = options.selector
this.type = options.type
@ -73,7 +78,9 @@ MenuItem = (function () {
}
if (this.role && rolesMap[this.role] && process.platform !== 'darwin' && (focusedWindow != null)) {
methodName = rolesMap[this.role]
if (methodInBrowserWindow[methodName]) {
if(methodInApp[methodName]) {
return app[methodName]()
} else if (methodInBrowserWindow[methodName]) {
return focusedWindow[methodName]()
} else {
return (ref2 = focusedWindow.webContents) != null ? ref2[methodName]() : void 0