feat: tray — menu bar icon with context menu

main
boksbc 2026-05-11 21:57:47 +02:00
parent 364344c3ca
commit 03e4fd68d8
1 changed files with 26 additions and 0 deletions

26
electron/tray.js Normal file
View File

@ -0,0 +1,26 @@
const { Tray, Menu, nativeImage } = require('electron');
const path = require('path');
let tray = null;
function createTray({ onShow, onHide, onQuit }) {
const iconPath = path.join(__dirname, '../assets/fox-tray.png');
const icon = nativeImage.createFromPath(iconPath);
icon.setTemplateImage(true);
tray = new Tray(icon);
tray.setToolTip('Fox');
tray.setContextMenu(Menu.buildFromTemplate([
{ label: 'Fox öffnen', accelerator: 'Cmd+Shift+F', click: onShow },
{ label: 'Fox verstecken', click: onHide },
{ type: 'separator' },
{ label: 'Beenden', click: onQuit },
]));
tray.on('click', onShow);
return tray;
}
module.exports = { createTray };