node-ddk 任务栏,托盘,通知
https://blog.youkuaiyun.com/eli960/article/details/146207062
也可以下载demo直接演示
http://linuxmail.cn/go#node-ddk
在渲染进程(既web端)操作
import renderer, { NODEDDK } from "node-ddk/renderer"
let w = renderer.window
// 让托盘闪动:10s
// tooltip:"test"
renderer.tray.startFlashing({ period: 10 * 1000, tooltip: "test" })
// 让托盘停止闪动
renderer.tray.stopFlashing()
// 设置托盘 tooltip
renderer.tray.setToolTip("提醒" + (new Date()).toString() + " OK")
// 设置 当窗口失去焦点后, 任务栏闪动
renderer.window.startFlash()
// 系统通知
renderer.systemNotification.notify({ title: "通知title", body: "通知正文", silent }).then(r => {
if (r == "click") {
console.log("点击查看")
} else {
console.log("未点击查看: " + r)
}
})
在主进程操作
import main, { NODEDDK } from "node-ddk/main"
// 设置程序图片
main.app.setFavicon(main.app.getPathInPublic("icons/favicon.png"))
// 设置图片图标, 默认图标
main.tray.setDefaultImage(main.app.getPathInPublic("icons/favicon.png"))
// 设置图片图标, 空白图标, (用于图片闪动)
main.tray.setBlankImage(main.app.getPathInPublic("icons/favicon_blank.png"))
// 托盘点击, 显示隐藏主窗口,显示主窗口,隐藏主窗口
main.tray.setShowHideSwitchMainWindowOnClick()
main.tray.setShowMainWindowOnClick()
main.tray.setHideMainWindowOnClick()
// 托盘右键菜单
main.tray.setContextMenu([
{
label: "显示主窗口",
click: async () => {
let w = await main.window.getMainWindow()
if (w) {
w.showInactive()
w.show()
}
}
},
{
label: "退出",
click: async () => {
main.app.quit()
}
},
])
671

被折叠的 条评论
为什么被折叠?



