gpt4 book ai didi

node.js - 删除 Node 通知程序中的终端图标

转载 作者:IT老高 更新时间:2023-10-28 23:01:35 25 4
gpt4 key购买 nike

我正在使用 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
});

通知是这样的:

enter image description here

如您所见,终端图标出现在名称之前。

你能帮我删除那个图标吗?

最佳答案

node-notifier 的已知问题.

来自 issue #71 :

mikaelbr :

No, I'm afraid that's how the notification work, as it's the terminal that initiates the message. The only way to avoid this is to use your custom terminal-notifier where the Terminal icon is swapped for your own. It's not a big task, and you can easily set customPath for notification center reporter.

kurisubrooks :

This happens because of the way notifications in OS X work. The notification will show the referring app icon, and because we're using terminal-notifier to push notifications, we have the icon of terminal-notifier.

To work around this, you'll need to compile terminal-notifier with your own app.icns. Download the source, change out the AppIcon bundle with your own in Xcode, recompile terminal-notifier and pop it into node-notifier. (/node-notifier/vendor/terminal-notifier.app)

Now that you have your own terminal-notifier inside node-notifier, remove all the icon references from your OS X Notification Center code, and run the notification as if it has no icon. If the old app icon is showing in your notifications, you need to clear your icon cache. (Google how to do this)

来自 mikaelb 的另一条有值(value)的评论:

That's correct. But keep in mind, node-notifier uses a fork of terminal-notifier (github.com/mikaelbr/terminal-notifier) to add option to wait for notification to finish, so this should be used to add your own icon. A easy way to do it is to copy/paste from the vendor-folder and use customPath to point to your own vendor.

关于node.js - 删除 Node 通知程序中的终端图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35002117/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com