mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2024-11-22 21:42:46 +01:00
33 lines
710 B
TypeScript
33 lines
710 B
TypeScript
import { BrowserWindow, Tray } from "electron";
|
|
import { getMenu } from "./menu";
|
|
|
|
let tray: Tray;
|
|
|
|
export const addTray = function (mainWindow: BrowserWindow, 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();
|
|
}
|
|
});
|
|
};
|
|
|
|
export const refreshTray = function (mainWindow: BrowserWindow) {
|
|
if (!tray) {
|
|
addTray(mainWindow);
|
|
}
|
|
};
|