Skip to content

Commit

Permalink
Minimize to tray, open Links in Browser
Browse files Browse the repository at this point in the history
  • Loading branch information
ClocxHD committed Jan 6, 2018
1 parent 538d013 commit 6178a23
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {app, BrowserWindow} = require('electron');
const {app, BrowserWindow, shell, Tray, Menu} = require('electron');
const path = require('path');

let mainWindow;
Expand All @@ -23,11 +23,49 @@ app.on('ready', function () {
mainWindow.setMenu(null);

mainWindow.loadURL('https://www.meistertask.com/app/dashboard');

const appIcon = new Tray(path.join(__dirname, '/assets/icons/icon.png'));
const contextMenu = Menu.buildFromTemplate([
{
label: 'Show App', click: function () {
mainWindow.show();
}
},
{
label: 'Quit', click: function () {
app.isQuitting = true;
app.quit();
}
}
]);

appIcon.setContextMenu(contextMenu);
appIcon.setToolTip("MeisterTask Unofficial");

mainWindow.on('ready-to-show', () => {
mainWindow.show();
});

mainWindow.focus();

mainWindow.on('closed', function () {
mainWindow = null;
});

mainWindow.on('minimize',function(event){
event.preventDefault();
mainWindow.hide();
});

mainWindow.webContents.on('new-window', function (e, url) {
e.preventDefault();
const protocol = require('url').parse(url).protocol;
if (protocol === "http:" || protocol === 'https:') {
shell.openExternal(url)
}
});

appIcon.on('click', function () {
mainWindow.show();
});
});

0 comments on commit 6178a23

Please sign in to comment.