Show/hide window when clicking on tray

This commit is contained in:
TC
2020-04-26 16:25:37 +02:00
parent 430687f4d6
commit 058371ace8
2 changed files with 7 additions and 1 deletions

View File

@ -166,7 +166,10 @@ app.on("activate", () => {
app.on("ready", () => {
setApplicationMenu();
mainWindow = createMainWindow();
setUpTray(app, mainWindow);
const tray = setUpTray(app, mainWindow);
tray.on("click", () => {
mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
});
if (!is.dev() && autoUpdate()) {
autoUpdater.checkForUpdatesAndNotify();

View File

@ -22,6 +22,7 @@ module.exports.setUpTray = (app, win) => {
});
tray = new Tray(trayIcon);
tray.setToolTip("Youtube Music");
tray.setIgnoreDoubleClickEvents(true);
const trayMenu = Menu.buildFromTemplate([
{
@ -66,4 +67,6 @@ module.exports.setUpTray = (app, win) => {
},
]);
tray.setContextMenu(trayMenu);
return tray;
};