Rag*_*hav 16 osx-snow-leopard node.js atom-editor electron
我使用https://github.com/mikaelbr/node-notifier包在shell中显示通知.
这是我的代码:
var notifier = require('node-notifier');
var path = require('path');
notifier.notify({
title: 'My awesome title',
message: 'Hello from node, Mr. User!',
icon: path.join(__dirname, 'coulson.jpg'), // absolute path (not balloons)
sound: true, // Only Notification Center or Windows Toasters
wait: true // wait with callback until user action is taken on notification
}, function (err, response) {
// response is response from notification
});
notifier.on('click', function (notifierObject, options) {
// Happens if `wait: true` and user clicks notification
});
notifier.on('timeout', function (notifierObject, options) {
// Happens if `wait: true` and notification closes
});
Run Code Online (Sandbox Code Playgroud)
通知如下:
如您所见,终端图标即将出现在名称之前.
你能帮我解决一下这个图标的问题吗?
Ale*_*r M 10
从问题#71:
不,我担心通知是如何工作的,因为它是发起消息的终端.避免这种情况的唯一方法是使用自定义终端通知程序,其中终端图标被替换为您自己的终端图标.这不是一项大任务,您可以轻松地为通知中心记者设置customPath.
这是因为OS X中的通知工作方式.通知将显示引用的应用程序图标,因为我们使用终端通知程序来推送通知,所以我们有终端通知程序的图标.
要解决此问题,您需要使用自己的app.icns编译终端通知程序.下载源代码,在Xcode中更改自己的AppIcon包,重新编译终端通知程序并将其弹出到node-notifier中.(
/node-notifier/vendor/terminal-notifier.app)既然您已在node-notifier中拥有自己的终端通知程序,请从OS X Notification Center代码中删除所有图标引用,并运行通知,就好像它没有图标一样.如果您的通知中显示旧的应用图标,则需要清除图标缓存.(谷歌如何做到这一点)
mikaelb的另一个有价值的评论:
那是对的.但请记住,node-notifier使用终端通知器的分支(github.com/mikaelbr/terminal-notifier)来添加等待通知完成的选项,因此这应该用于添加您自己的图标.一种简单的方法是从vendor-folder复制/粘贴并使用
customPath指向您自己的供应商.
| 归档时间: |
|
| 查看次数: |
2252 次 |
| 最近记录: |