mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-11-11 15:51:06 +00:00
Temporarily undo linux tray to fix other bugs
This commit is contained in:
parent
362b48c411
commit
99278cfa49
@ -39,7 +39,7 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
|
|||||||
preload: path.join(__dirname, 'static', 'preload.js')
|
preload: path.join(__dirname, 'static', 'preload.js')
|
||||||
},
|
},
|
||||||
// after webpack path here should reference `resources/app/`
|
// after webpack path here should reference `resources/app/`
|
||||||
icon: options.icon
|
icon: path.join(__dirname, '../', '/icon.png')
|
||||||
});
|
});
|
||||||
|
|
||||||
let currentZoom = 1;
|
let currentZoom = 1;
|
||||||
|
@ -12,20 +12,12 @@ const {isOSX} = helpers;
|
|||||||
const APP_ARGS_FILE_PATH = path.join(__dirname, '..', 'nativefier.json');
|
const APP_ARGS_FILE_PATH = path.join(__dirname, '..', 'nativefier.json');
|
||||||
const appArgs = JSON.parse(fs.readFileSync(APP_ARGS_FILE_PATH, 'utf8'));
|
const appArgs = JSON.parse(fs.readFileSync(APP_ARGS_FILE_PATH, 'utf8'));
|
||||||
|
|
||||||
const DEFAULT_ICON_PATH = path.join(__dirname, '..', '/icon.png');
|
|
||||||
const Tray = electron.Tray;
|
|
||||||
const Menu = electron.Menu;
|
|
||||||
|
|
||||||
let mainWindow;
|
let mainWindow;
|
||||||
|
|
||||||
if (appArgs.insecure) {
|
if (appArgs.insecure) {
|
||||||
app.commandLine.appendSwitch('ignore-certificate-errors');
|
app.commandLine.appendSwitch('ignore-certificate-errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!appArgs.icon) {
|
|
||||||
appArgs.icon = DEFAULT_ICON_PATH;
|
|
||||||
}
|
|
||||||
|
|
||||||
// do nothing for setDockBadge if not OSX
|
// do nothing for setDockBadge if not OSX
|
||||||
let setDockBadge = () => {};
|
let setDockBadge = () => {};
|
||||||
|
|
||||||
@ -34,12 +26,6 @@ if (isOSX()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
// Need a better place to store user options, unless you intend to dump everything into cli
|
|
||||||
// determined opts
|
|
||||||
if (appArgs.minimizeToTray) {
|
|
||||||
mainWindow.hide();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!isOSX()) {
|
if (!isOSX()) {
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
@ -66,47 +52,8 @@ app.on('before-quit', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let appIcon = null;
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
mainWindow = createMainWindow(appArgs, app.quit, setDockBadge);
|
mainWindow = createMainWindow(appArgs, app.quit, setDockBadge);
|
||||||
mainWindow.on('close', e => {
|
|
||||||
if (!mainWindow.forceClose && appArgs.minimizeToTray) {
|
|
||||||
e.preventDefault();
|
|
||||||
mainWindow.hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
appIcon = new Tray(appArgs.icon);
|
|
||||||
let menu = Menu.buildFromTemplate([
|
|
||||||
// See https://github.com/atom/electron/blob/master/docs/api/tray.md for why
|
|
||||||
// there is a shitty option to show
|
|
||||||
{
|
|
||||||
label: 'Show',
|
|
||||||
type: 'normal',
|
|
||||||
click: function() {
|
|
||||||
mainWindow.show();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Minimize to Tray',
|
|
||||||
type: 'checkbox',
|
|
||||||
checked: appArgs.minimizeToTray || false,
|
|
||||||
click: function(menuItem) {
|
|
||||||
appArgs.minimizeToTray = menuItem.checked;
|
|
||||||
fs.writeFileSync(APP_ARGS_FILE_PATH, JSON.stringify(appArgs));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Close',
|
|
||||||
type: 'normal',
|
|
||||||
click: function() {
|
|
||||||
mainWindow.forceClose = true;
|
|
||||||
app.quit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
appIcon.setContextMenu(menu);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('login', (event, webContents, request, authInfo, callback) => {
|
app.on('login', (event, webContents, request, authInfo, callback) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user