【发布时间】:2019-08-29 13:21:16
【问题描述】:
我正在尝试在 Ubuntu 18.04 的托盘栏上显示我的应用程序。
使用此代码
const {app, Menu, Tray} = require('electron')
let tray = null
app.on('ready', () => {
tray = new Tray(__dirname+'/icongradient.png')
const contextMenu = Menu.buildFromTemplate([
{label: 'Item1', type: 'normal',icon:__dirname+'/icongradient.png'},
{label: 'Item2', type: 'radio'},
{label: 'Item3', type: 'radio', checked: true},
{label: 'Item4', type: 'radio'}
])
tray.setToolTip('This is my application.')
tray.setContextMenu(contextMenu)
})
它根本没有显示,安装libappindicator库后,当我点击图标应该在的空间但图标没有显示时,上下文菜单出现了。
我也在控制台中收到此警告。
(electron:11502): libappindicator-WARNING **: 12:48:23.673: Using '/tmp' paths in SNAP environment will lead to unreadable resources
【问题讨论】:
-
我也面临同样的问题。你能解决吗?
标签: electron ubuntu-18.04