Javascript [Electron][OSX]始终显示托盘图标
我正在用Electron编写一个OSX应用程序,Javascript [Electron][OSX]始终显示托盘图标,javascript,node.js,macos,operating-system,electron,Javascript,Node.js,Macos,Operating System,Electron,我正在用Electron编写一个OSX应用程序, 它主要集中在托盘上。基本上,它只显示应用程序当前正在使用的时间,我如何设置它,使其独立于窗口?您只需在主进程中创建托盘,而不创建窗口 const {app, Menu, Tray} = require('electron') let tray = null app.on('ready', () => { tray = new Tray('/path/to/my/icon') const contextMenu = Menu.bui
它主要集中在托盘上。基本上,它只显示应用程序当前正在使用的时间,我如何设置它,使其独立于窗口?您只需在主进程中创建托盘,而不创建窗口
const {app, Menu, Tray} = require('electron')
let tray = null
app.on('ready', () => {
tray = new Tray('/path/to/my/icon')
const contextMenu = Menu.buildFromTemplate([
{label: 'Item1', type: 'radio'},
{label: 'Item2', type: 'radio'},
{label: 'Item3', type: 'radio', checked: true},
{label: 'Item4', type: 'radio'}
])
tray.setToolTip('This is my application.')
tray.setContextMenu(contextMenu)
})