Hide from Dock on macOS when the tray icon is enabled and the window is closed

This commit is contained in:
Botond Horvath 2018-07-21 18:37:39 +02:00 committed by Ken Powers
parent bc6d549f20
commit ffb0b5a27b
3 changed files with 29 additions and 0 deletions

View file

@ -2,6 +2,7 @@ const path = require('path');
const fs = require('fs');
const { app, Menu, Tray } = require('electron');
const dockIcon = require('./dock_icon');
let trayContextMenu = null;
let tray = null;
@ -34,8 +35,10 @@ function createTrayIcon(getMainWindow, messages) {
if (mainWindow) {
if (mainWindow.isVisible()) {
mainWindow.hide();
dockIcon.hide();
} else {
mainWindow.show();
dockIcon.show();
tray.forceOnTop(mainWindow);
}