Fix #486 : --tray flag crashes nativefied app under Windows (PR #495)

This commit is contained in:
omouren 2017-11-26 05:27:19 +01:00 committed by Ronan Jouchet
parent 8963544afa
commit 1c8d04e532
3 changed files with 14 additions and 6 deletions

View File

@ -7,7 +7,7 @@ import createMenu from './../menu/menu';
import initContextMenu from './../contextMenu/contextMenu';
const {
isOSX, linkIsInternal, getCssToInject, shouldInjectCss,
isOSX, linkIsInternal, getCssToInject, shouldInjectCss, getAppIcon,
} = helpers;
const ZOOM_INTERVAL = 0.1;
@ -86,7 +86,7 @@ function createMainWindow(inpOptions, onAppQuit, setDockBadge) {
zoomFactor: options.zoom,
},
// after webpack path here should reference `resources/app/`
icon: path.join(__dirname, '../', '/icon.png'),
icon: getAppIcon(),
// set to undefined and not false because explicitly setting to false will disable full screen
fullscreen: options.fullScreen || undefined,
});

View File

@ -1,9 +1,11 @@
import path from 'path';
import helpers from './../../helpers/helpers';
const {
app, Tray, Menu, ipcMain,
app, Tray, Menu, ipcMain, nativeImage,
} = require('electron');
const { getAppIcon } = helpers;
/**
*
* @param {{}} inpOptions AppArgs from nativefier.json
@ -14,8 +16,9 @@ function createTrayIcon(inpOptions, mainWindow) {
const options = Object.assign({}, inpOptions);
if (options.tray) {
const iconPath = path.join(__dirname, '../', '/icon.png');
const appIcon = new Tray(iconPath);
const iconPath = getAppIcon();
const nimage = nativeImage.createFromPath(iconPath);
const appIcon = new Tray(nimage);
const onClick = () => {
if (mainWindow.isVisible()) {

View File

@ -55,6 +55,10 @@ function debugLog(browserWindow, message) {
console.log(message);
}
function getAppIcon() {
return path.join(__dirname, '../', `/icon.${isWindows() ? 'ico' : 'png'}`);
}
export default {
isOSX,
isLinux,
@ -63,4 +67,5 @@ export default {
getCssToInject,
debugLog,
shouldInjectCss,
getAppIcon,
};