我可以使用 node-notifier
从 electron 发送 windows 通知
notifier.notify({
appName: "myapp",
title: 'My notification',
message: 'Hello, there!'
});
我可以使用 node-windows
从 electron 运行服务
从我的主进程
var svc = new Service({
name: 'MyService',
description: '',
script: 'MyService.js',
});
svc.on('install', function () {
console.log('Install complete.');
svc.start();
});
svc.install();
但是,当我尝试从由 Electron 创建的服务发送通知时,却没有出现。虽然我检查了服务中的代码在日志中没有任何错误地运行!
我知道这在 C# 中是可能的,但我如何在 Electron 中做到这一点?
任何指南如何从服务发送通知?
谢谢
最佳答案
尝试使用内置 Electron 通知,文档在这里:https://electronjs.org/docs/tutorial/notifications . 如果您尝试过但它不起作用,您一定要错过:
On Windows 10, a shortcut to your app with an Application User Model ID must be installed to the Start Menu.
你必须在主进程中设置AppID,只需将这行放在主进程中:app.setAppUserModelId('yourappid')
希望对你有帮助
关于node.js - 来自 Electron 的 Node 服务的 Windows 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52065533/