feat: tray — menu bar icon with context menu
parent
364344c3ca
commit
03e4fd68d8
|
|
@ -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 };
|
||||
Loading…
Reference in New Issue