Refactorize hardcoded icon path to main.js for more general usage

This commit is contained in:
zweicoder 2016-01-27 23:30:54 +08:00
parent 8041663d82
commit 7273a63885
2 changed files with 12 additions and 2 deletions

View File

@ -39,7 +39,8 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
preload: path.join(__dirname, 'static', 'preload.js')
},
// after webpack path here should reference `resources/app/`
icon: path.join(__dirname, '../', '/icon.png')
icon: options.icon
//icon: path.join(__dirname, '../', '/icon.png')
});
let currentZoom = 1;

View File

@ -10,15 +10,21 @@ const {app, ipcMain} = electron;
const {isOSX} = helpers;
const APP_ARGS_FILE_PATH = path.join(__dirname, '..', 'nativefier.json');
const appArgs = JSON.parse(fs.readFileSync(APP_ARGS_FILE_PATH, 'utf8'));
const DEFAULT_ICON_PATH = path.join(__dirname, '/icon.png');
const Tray = electron.Tray;
let mainWindow;
if (appArgs.insecure) {
app.commandLine.appendSwitch('ignore-certificate-errors');
}
if(!appArgs.icon){
appArgs.icon = DEFAULT_ICON_PATH;
}
// do nothing for setDockBadge if not OSX
let setDockBadge = () => {};
@ -53,8 +59,11 @@ app.on('before-quit', () => {
}
});
let appIcon = null;
app.on('ready', () => {
mainWindow = createMainWindow(appArgs, app.quit, setDockBadge);
appIcon = new Tray(appArgs.icon);
});
app.on('login', (event, webContents, request, authInfo, callback) => {