2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-12-23 02:28:55 +00:00

Remove "About Electron" from app menu, add nativefier version to help, which fixes #18

Also refactor buildMenu function arguments
This commit is contained in:
Jia Hao 2016-01-21 13:42:27 +08:00
parent 82317a08d3
commit e8a7c634cd
3 changed files with 11 additions and 15 deletions

View File

@ -2,7 +2,7 @@ var electron = require('electron');
var Menu = electron.Menu;
var shell = electron.shell;
module.exports = function (app, mainWindow) {
module.exports = function (mainWindow, nativefierVersion, onQuit) {
if (Menu.getApplicationMenu())
return;
@ -120,7 +120,7 @@ module.exports = function (app, mainWindow) {
role: 'help',
submenu: [
{
label: 'Learn More About Nativefier',
label: `Built with Nativefier v${nativefierVersion}`,
click: function() { shell.openExternal('https://github.com/jiahaog/nativefier') }
},
{
@ -135,13 +135,6 @@ module.exports = function (app, mainWindow) {
template.unshift({
label: 'Electron',
submenu: [
{
label: 'About Electron',
role: 'about'
},
{
type: 'separator'
},
{
label: 'Services',
role: 'services',
@ -151,7 +144,7 @@ module.exports = function (app, mainWindow) {
type: 'separator'
},
{
label: 'Hide Electron',
label: 'Hide App',
accelerator: 'Command+H',
role: 'hide'
},
@ -170,7 +163,7 @@ module.exports = function (app, mainWindow) {
{
label: 'Quit',
accelerator: 'Command+Q',
click: function() { app.quit(); }
click: function() { onQuit(); }
},
]
});

View File

@ -57,7 +57,7 @@ app.on('ready', function () {
}
);
buildMenu(app, mainWindow);
buildMenu(mainWindow, appArgs.nativefierVersion, app.quit);
mainWindow.loadURL('file://' + __dirname + '/index.html');

View File

@ -8,6 +8,8 @@ import ncp from 'ncp';
import async from 'async';
import _ from 'lodash';
import packageJson from './../package.json';
const copy = ncp.ncp;
/**
@ -65,8 +67,8 @@ function buildApp(options, callback) {
* @param {tempDirCallback} callback
*/
function copyPlaceholderApp(srcAppDir, tempDir, name, targetURL, badge, width, height, userAgent, callback) {
copy(srcAppDir, tempDir, error => {
const loadedPackageJson = packageJson;
copy(srcAppDir, tempDir, function(error) {
if (error) {
console.error(error);
callback(`Error Copying temporary directory: ${error}`);
@ -79,7 +81,8 @@ function copyPlaceholderApp(srcAppDir, tempDir, name, targetURL, badge, width, h
badge: badge,
width: width,
height: height,
userAgent: userAgent
userAgent: userAgent,
nativefierVersion: loadedPackageJson.version
};
fs.writeFileSync(path.join(tempDir, '/nativefier.json'), JSON.stringify(appArgs));