[英]System tray icon in node.js application
這是我在我的 node.js 應用程序中需要的:
這是我發現的:
你有什么建議? 我需要可靠、易於安裝且盡可能跨系統的東西。
//編輯
自 11 月 6 日以來,Appjs 具有基本的托盤圖標支持。
對於來到這里的任何其他人,請查看https://github.com/rogerwang/node-webkit - 一個很棒的包,允許您使用您喜歡的工具(如 JavaScript)創建桌面應用程序,支持本機 shell 訪問、托盤圖標還有更多。
更新:該應用程序已移至NWjs.io ,但它是同樣出色的概念。
看看 Node-QT ( https://github.com/arturadib/node-qt ) 也許會有幫助。
我在 Linux 上使用過系統托盤。 它承諾也可以在 macOS 和 Windows 上運行。 但我沒有測試它。
來自官方文檔的示例:
import SysTray from 'systray'
const systray = new SysTray({
menu: {
// you should using .png icon in macOS/Linux, but .ico format in windows
icon: "<base64 image string>",
title: "標題",
tooltip: "Tips",
items: [{
title: "aa",
tooltip: "bb",
// checked is implement by plain text in linux
checked: true,
enabled: true
}, {
title: "aa2",
tooltip: "bb",
checked: false,
enabled: true
}, {
title: "Exit",
tooltip: "bb",
checked: false,
enabled: true
}]
},
debug: false,
copyDir: true, // copy go tray binary to outside directory, useful for packing tool like pkg.
})
systray.onClick(action => {
if (action.seq_id === 0) {
systray.sendAction({
type: 'update-item',
item: {
...action.item,
checked: !action.item.checked,
},
seq_id: action.seq_id,
})
} else if (action.seq_id === 1) {
// open the url
console.log('open the url', action)
} else if (action.seq_id === 2) {
systray.kill()
}
})
它不提供
創建帶有登錄/密碼字段和確認按鈕的窗口
但在我看來,這項任務是一個單獨的任務。 所以這個答案對其他只想要系統托盤圖標的人有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.