【发布时间】:2020-10-03 19:41:51
【问题描述】:
【问题讨论】:
-
这被称为系统托盘,Electron 实现了它throught the
Trayclass。看看那些文档。
标签: javascript node.js windows electron taskbar
【问题讨论】:
Tray class。看看那些文档。
标签: javascript node.js windows electron taskbar
该区域称为“系统托盘”,您可以使用 Electron 的托盘 API 为您的电子应用添加系统托盘图标。您可以找到documentation for the Tray class here,也可以查看this tutorial。
【讨论】:
// 电子任务栏
const {app, Tray, Menu} = require('electron')
app.on('ready', () => {
tray = new Tray(path.join(__dirname, 'icon/favicon.ico'))
if (process.platform === 'win32' ) {
tray.on('click', tray.popUpContextMenu)
}
const menu = Menu.buildFromTemplate ([
{
label: 'Exit',
click() { app.quit()}
},
{ label: 'Help',
click() { null; }}
])
tray.setToolTip('AppName')
tray.setContextMenu(menu)
})
【讨论】: