我正在使用 Windows 10,我尝试让通知保持打开状态,直到用户按下单击通知,但无论我尝试什么,通知都会在一段时间后消失,有一些方法可以使用库:node-notifier或与另一个图书馆?
const notifier = require("node-notifier");
const path = require("path");
var isClickNote = false;
function sendNote() {
notifier.notify(
{
title: "My awesome title",
message: "Hello from node, Mr. User!",
icon: path.join(__dirname, "coulson.jpg"), // Absolute path (doesn't work on balloons)
sound: true, // Only Notification Center or Windows Toasters
wait: true, // Wait with callback, until user action is taken against notification, does not apply to Windows Toasters as they always wait or notify-send as it does not support the wait option
},
function (err, response, metadata) {
// Response is response from notification
// Metadata contains activationType, activationAt, deliveredAt
}
);
notifier.on("click", function (notifierObject, options, event) {
isClickNote = true;
// console.log("notifierObject:", notifierObject);
// Triggers if `wait: true` and user clicks notification
});
notifier.on("timeout", function (notifierObject, options) {
// Triggers if `wait: true` and notification closes
});
}
sendNote();