标签: node-notifier

如何监听 Windows 通知上的点击事件?

我只是使用node-notifier包发送通知。此外,当我点击通知时,它必须转到一个链接。但是我听不到点击事件。包提供的事件什么都不做。这是我的代码:

const notifier = require("node-notifier");
const open = require("open");

notifier.notify({
  title: "Stackoverflow",
  message: "A message",
  wait: true,
  open: "https://stackoverflow.com/",
});

notifier.on("click", function (notifierObject, options, event) {
  open("https://sindresorhus.com");
});
Run Code Online (Sandbox Code Playgroud)

这是我的通知:

在此处输入图片说明

我可以使用任何其他包。我只想听点击事件。

@ user120242 的答案有效,但在通知消失后单击无效。有什么办法吗?我添加了一个gif

javascript node.js electron node-notifier

12
推荐指数
1
解决办法
928
查看次数

使用jest在nodejs中测试mail-notifier

有谁知道如何测试nodejs中的mail-notifier模块?我想测试里面的逻辑n.on():

const notifier = require('mail-notifier');

const imap = {
  user: 'mailId',
  password: 'password',
  host: 'host',
  port: 'port',
  tls: true,
  tlsOptions: { rejectUnauthorized: false }
};

const n = notifier(imap);

n.on('mail', async function (mail) {
  console.log('mail:', mail);
}).start();
Run Code Online (Sandbox Code Playgroud)

unit-testing node.js jestjs node-notifier

7
推荐指数
1
解决办法
237
查看次数

在 Windows 平台上启用电子应用程序通知的粘性行为

我想在电子桌面应用程序中实现通知的粘性行为,直到用户单击通知本身。

我正在使用node-notifier来实现此文档,并使用ngx-electron使用 ElectronService 在角度组件文件中导入 main.js 文件。

这是我的main.js文件:

const notifier = require('node-notifier')
exports.notifier = (msg) =>  {
  notifier.notify({
  title: 'Notify Me',
  message: msg,
  wait: true,
  timeout: 1500000,
  sound: true,
  icon:  './assets/images/logo.png'
});
Run Code Online (Sandbox Code Playgroud)

app.component.ts :

import {ElectronService} from 'ngx-electron';
@Component({
  selector: 'app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
  public main_js : any;

  constructor(private _electronService: ElectronService ) { 
    this.main_js  = this._electronService.remote.require("./main.js");
    this.getTasks();
  }

  getTasks() {
    var message = 'New Task …
Run Code Online (Sandbox Code Playgroud)

javascript notifications electron node-notifier angular

5
推荐指数
1
解决办法
1027
查看次数

具有节点通知器的电子显示窗口10通知

我正在尝试创建一个简单的应用程序,它应该在单击按钮时显示通知.问题是通知没有显示,但是console.logs正在显示.通知应该在开发模式下工作吗?(意思是刚刚运行electron .,我不需要构建和安装应用程序)

Windows操作系统:

  • 版本:Windows 10 Home
  • 版本:1709
  • 构建:16299.98
  • 注意:启用Toast(横幅,操作中心) System->Notification & Actions

码:

// main.js
const { app, BrowserWindow, ipcMain, Notification } = require("electron");

const path = require("path");
const url = require("url");

let win;

function createWindow() {
  // Create the browser window.
  win = new BrowserWindow({ width: 800, height: 600 });

  // and load the index.html of the app.
  win.loadURL(
    url.format({
      pathname: path.join(__dirname, "index.html"),
      protocol: "file:",
      slashes: true
    })
  );

  // Open the DevTools.
  // win.webContents.openDevTools()

  // Emitted …
Run Code Online (Sandbox Code Playgroud)

node.js electron node-notifier

4
推荐指数
1
解决办法
4250
查看次数