feat: initial commit
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import { resolve } from "node:path";
|
||||
|
||||
import { Menu, Tray, nativeImage } from "electron";
|
||||
|
||||
import { version } from "../../package.json";
|
||||
|
||||
import { mainWindow, quitApp } from "./window";
|
||||
|
||||
// internal tray state
|
||||
let tray: Tray = null;
|
||||
|
||||
// load the tray icon
|
||||
const trayIcon = nativeImage.createFromPath(
|
||||
resolve(process.resourcesPath, "icon.png"),
|
||||
);
|
||||
|
||||
// trayIcon.setTemplateImage(true);
|
||||
|
||||
export function initTray() {
|
||||
tray = new Tray(trayIcon);
|
||||
updateTrayMenu();
|
||||
tray.setToolTip("Stoat for Desktop");
|
||||
tray.setImage(trayIcon);
|
||||
}
|
||||
|
||||
export function updateTrayMenu() {
|
||||
tray.setContextMenu(
|
||||
Menu.buildFromTemplate([
|
||||
{ label: "Stoat for Desktop", type: "normal", enabled: false },
|
||||
{
|
||||
label: "Version",
|
||||
type: "submenu",
|
||||
submenu: Menu.buildFromTemplate([
|
||||
{
|
||||
label: version,
|
||||
type: "normal",
|
||||
enabled: false,
|
||||
},
|
||||
]),
|
||||
},
|
||||
{ type: "separator" },
|
||||
{
|
||||
label: mainWindow.isVisible() ? "Hide App" : "Show App",
|
||||
type: "normal",
|
||||
click() {
|
||||
if (mainWindow.isVisible()) {
|
||||
mainWindow.hide();
|
||||
} else {
|
||||
mainWindow.show();
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "Quit App",
|
||||
type: "normal",
|
||||
click: quitApp,
|
||||
},
|
||||
]),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user