27 lines
684 B
JavaScript
27 lines
684 B
JavaScript
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 };
|