mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2025-05-14 06:43:05 +02:00
35 lines
728 B
JavaScript
35 lines
728 B
JavaScript
const { Tray } = require("electron");
|
|
const { getMenu } = require("./menu");
|
|
const trayModule = {};
|
|
let tray;
|
|
|
|
trayModule.addTray = function (mainWindow, options = { icon: "" }) {
|
|
tray = new Tray(options.icon);
|
|
tray.setIgnoreDoubleClickEvents(true);
|
|
tray.setToolTip("Tidal-hifi");
|
|
|
|
const menu = getMenu(mainWindow);
|
|
|
|
tray.setContextMenu(menu);
|
|
|
|
tray.on("click", function () {
|
|
if (mainWindow.isVisible()) {
|
|
if (!mainWindow.isFocused()) {
|
|
mainWindow.focus();
|
|
} else {
|
|
mainWindow.hide();
|
|
}
|
|
} else {
|
|
mainWindow.show();
|
|
}
|
|
});
|
|
};
|
|
|
|
trayModule.refreshTray = function (mainWindow) {
|
|
if (!tray) {
|
|
trayModule.addTray(mainWindow);
|
|
}
|
|
};
|
|
|
|
module.exports = trayModule;
|