国外优秀设计网站推荐,青海城乡建设部网站,成都房地产公司排行榜,网站右侧二维码代码问题描述
electron 设置开机自启动后 托盘图标无法显示
问题解决
tray new Tray(path.join(__dirname, ./public/logo.png)); //必须是绝对路径和扩展名#xff0c;像.png等我的问题是图标之前设置为相对路径#xff0c;而导致无法显示。将Tray的图标路径设定为绝对路径后…问题描述
electron 设置开机自启动后 托盘图标无法显示
问题解决
tray new Tray(path.join(__dirname, ./public/logo.png)); //必须是绝对路径和扩展名像.png等
我的问题是图标之前设置为相对路径而导致无法显示。将Tray的图标路径设定为绝对路径后问题解决。
扩展
自启动的两种方式
通过自带API app.setLoginItemSettings({openAtLogin: true,path: app.getPath(exe),});通过插件jsoncelectron-auto-launch
const AutoLaunch require(electron-auto-launch);let autoLaunch new AutoLaunch({name: 可执行文件名称,path: app.getPath(exe),
});autoLaunch.isEnabled().then((isEnabled) {if (!isEnabled) autoLaunch.enable();
});