[英]setBadgeCount() not working after running electron-builder
运行electron-builder
后setBadgeCount()
不起作用
在本地运行时一切正常,但是当我运行yarn electron-builder
时,无论我使用什么方法,分布式应用程序都不会更新徽章计数。 我检查了我的 repo 中的 build 文件夹,编译后的 function 就在那里。 突破步骤是在electron-builder
部署中的某个地方。
electron: "^8.2.3"
electron-builder: "^22.5.1"
const { app } = window.require('electron').remote;
function openCountText(count) {
let badgeCount = `(${count}) `;
if (!count) badgeCount = '';
if (count > 9) badgeCount = '(9+) ';
// Sets the badge count on the Desktop Application
!!count && !!app && app.dock.setBadgeCount(count)
return badgeCount;
}
!!count && !!app && app.dock.setBadge(`${count}`)
!!count && !!app && app.dock.setBadge("19")
!!count && !!app && app.setBadgeCount(2)
尝试使用:
const { app } = require('electron');
let badgeCount = 0;
app.setBadgeCount(badgeCount + 1);
// `0` will hide the badge.
app.setBadgeCount(badgeCount = 0);
文档https://www.electronjs.org/docs/api/app#appsetbadgecountcount-linux-macos
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.