Merge pull request #1505 from atom/default-help-menu

Add help menu to default app
This commit is contained in:
Cheng Zhao 2015-04-28 17:55:06 +08:00
commit f5fbd52dbd
2 changed files with 65 additions and 8 deletions

View file

@ -112,11 +112,12 @@ app.on('ready', function() {
click: function() { mainWindow.restart(); } click: function() { mainWindow.restart(); }
}, },
{ {
label: 'Enter Fullscreen', label: 'Toggle Full Screen',
click: function() { mainWindow.setFullScreen(true); } accelerator: 'Ctrl+Command+F',
click: function() { mainWindow.setFullScreen(!mainWindow.isFullScreen()); }
}, },
{ {
label: 'Toggle DevTools', label: 'Toggle Developer Tools',
accelerator: 'Alt+Command+I', accelerator: 'Alt+Command+I',
click: function() { mainWindow.toggleDevTools(); } click: function() { mainWindow.toggleDevTools(); }
}, },
@ -144,6 +145,27 @@ app.on('ready', function() {
}, },
] ]
}, },
{
label: 'Help',
submenu: [
{
label: 'Learn More',
click: function() { require('shell').openExternal('http://electron.atom.io') }
},
{
label: 'Documentation',
click: function() { require('shell').openExternal('https://github.com/atom/electron/tree/master/docs#readme') }
},
{
label: 'Community Discussions',
click: function() { require('shell').openExternal('https://discuss.atom.io/c/electron') }
},
{
label: 'Search Issues',
click: function() { require('shell').openExternal('https://github.com/atom/electron/issues') }
}
]
}
]; ];
menu = Menu.buildFromTemplate(template); menu = Menu.buildFromTemplate(template);
@ -173,16 +195,38 @@ app.on('ready', function() {
click: function() { mainWindow.restart(); } click: function() { mainWindow.restart(); }
}, },
{ {
label: '&Enter Fullscreen', label: 'Toggle &Full Screen',
click: function() { mainWindow.setFullScreen(true); } accelerator: 'F11',
click: function() { mainWindow.setFullScreen(!mainWindow.isFullScreen()); }
}, },
{ {
label: '&Toggle DevTools', label: 'Toggle &Developer Tools',
accelerator: 'Alt+Ctrl+I', accelerator: 'Alt+Ctrl+I',
click: function() { mainWindow.toggleDevTools(); } click: function() { mainWindow.toggleDevTools(); }
}, },
] ]
}, },
{
label: 'Help',
submenu: [
{
label: 'Learn More',
click: function() { require('shell').openExternal('http://electron.atom.io') }
},
{
label: 'Documentation',
click: function() { require('shell').openExternal('https://github.com/atom/electron/tree/master/docs#readme') }
},
{
label: 'Community Discussions',
click: function() { require('shell').openExternal('https://discuss.atom.io/c/electron') }
},
{
label: 'Search Issues',
click: function() { require('shell').openExternal('https://github.com/atom/electron/issues') }
}
]
}
]; ];
menu = Menu.buildFromTemplate(template); menu = Menu.buildFromTemplate(template);

View file

@ -11,11 +11,14 @@ app.on('window-all-closed', function() {
// Parse command line options. // Parse command line options.
var argv = process.argv.slice(1); var argv = process.argv.slice(1);
var option = { file: null, version: null, webdriver: null }; var option = { file: null, help: null, version: null, webdriver: null };
for (var i in argv) { for (var i in argv) {
if (argv[i] == '--version' || argv[i] == '-v') { if (argv[i] == '--version' || argv[i] == '-v') {
option.version = true; option.version = true;
break; break;
} else if (argv[i] == '--help' || argv[i] == '-h') {
option.help = true;
break;
} else if (argv[i] == '--test-type=webdriver') { } else if (argv[i] == '--test-type=webdriver') {
option.webdriver = true; option.webdriver = true;
} else if (argv[i][0] == '-') { } else if (argv[i][0] == '-') {
@ -58,7 +61,17 @@ if (option.file && !option.webdriver) {
} }
} }
} else if (option.version) { } else if (option.version) {
console.log('v' + process.versions['electron']); console.log('v' + process.versions.electron);
process.exit(0);
} else if (option.help) {
var helpMessage = "Electron v" + process.versions.electron + " - Cross Platform Desktop Application Shell\n\n";
helpMessage += "Usage: electron [options] [path]\n\n";
helpMessage += "A path to an Electron application may be specified. The path must be to \n";
helpMessage += "an index.js file or to a folder containing a package.json or index.js file.\n\n";
helpMessage += "Options:\n";
helpMessage += " -h, --help Print this usage message.\n";
helpMessage += " -v, --version Print the version.";
console.log(helpMessage);
process.exit(0); process.exit(0);
} else { } else {
require('./default_app.js'); require('./default_app.js');