node-notifier
基本使用
const notifier = require('node-notifier');
notifier.notify({
title: 'My notification',
message: 'Hello, there!',
icon: ''
})
全量参数
const notifier = require('node-notifier');
notifier.notify({
title: 'My notification',
message: 'Hello, there!',
icon: '',
sound: true,
wait: true,
id: void 0,
appID: void 0,
remove: void 0,
install: void 0,
time: 5000,
type: 'info',
}, (err, resp) => {
console.log(err, resp)
});
notifier.on('click', function(notifierObject, options) {
console.log('on click', notifierObject, options)
});
notifier.on('timeout', function(notifierObject, options) {
console.log('on timeout', notifierObject, options)
});
按需引入(只举例 windows toaster/Balloon)
const WindowsToaster = require('node-notifier/notifiers/toaster');
const WindowsBalloon = require('node-notifier/notifiers/balloon');
const configOptions = {
}
const options = {
title: 'My notification',
message: 'Hello, there!',
icon: '',
sound: true,
wait: false,
}
new WindowsToaster(configOptions).notify(options);
new WindowsBalloon(configOptions).notify(options);
注意事项
- win8: 图片须为 png,不大于 1024*1024px,须小于200kb,须使用绝对路径
- win10 秋季创造者更新:在这个版本下,似乎要指定唯一的
appID
才能正确使用 notifier