npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

electron-notifications-lite

v1.2.1

Published

A node module for sending notifications in electron applications

Downloads

16

Readme

Electron Notifications Lite

关于Electron的notification,先总结我的经验。Mac下直接用electron的notification module就可以。Win下的notification如果想要用win原生的,会有一些问题。Win7和win8/8.1/10在用户体验和内容上差别很大,前者为气泡,后者为Metro风格的。electron自己的notification现在这个版本(18-01-01)在win下问题很多。另外,electron-windows-notifcation这个在8/8.1/10上表现很好,但是不支持7,但7很用户量更大。

所以还是用这个electron-notifications,它是直接用browserwindow模拟的notification,原本的UI比较丑、Bug也很多,并且细节上闪烁也比较严重,但它会是比较稳定的(因为其原理)。原来的项目bug提了很久也不修,似乎作者并不想维护了。而A.F.C App正好有这个需求,因而在原fork基础上进行了一些工作。

本分支附加了-lite作为名字,您可安装:

npm install --save electron-notifications-lite 

当前状态说明:

  • 不再支持所谓的vertical 模式,不再支持按钮。
  • 当Notification被点击时,它会向主线程发notification-lite-click的消息。
  • option中增加一个adicon字段,能够额外在右侧显示一个ICON。

Changelog:

1.1.1

  • notification不再抢走焦点

1.1.2

  • 增加autoClose选项

其他说明见原fork稳定:


A node module for sending notifications in electron applications.

screenshot

Quick Usage

const notifier = require('electron-notifications')

// Just title
notifier.notify('Calendar')

// Full Options
notifier.notify('Calendar', {
  message: 'Event begins in 10 minutes',
  icon: 'http://cl.ly/J49B/3951818241085781941.png',
  buttons: ['Dismiss', 'Snooze'],
})

Installation

npm install --save electron-notifications

Playbook

If you'd like to see this in action you can run the playbook and try out live examples and edit the code in place.

git clone [email protected]:blainesch/electron-notifications.git
npm run playbook

Introduction

When you create a new notification, your notification is queued, since we only display one at a time. Each notification is a BrowserWindow instance, so it's completely cross platform.

Options

All options are optional.

  • message: A message to display under the title.
  • icon: The absolute URL of a icon displayed to the left of the text.
  • buttons: One or two buttons to display on the right of the notification.
  • vertical: Boolean (default: false) that specifies that the buttons should be stacked vertically.
  • duration: Integer duration in milliseconds (default: 4000) to show the notification.
  • flat: Boolean (default: false) that specifies to use a flat button style notification.

Events

In addition to the events provided by electron you also have access to the following 3 additional events.

Clicked

When the notification was clicked, but not dragged. This usually does the default action, or closes the notification.

const notification = notifier.notify('Calendar')

notification.on('clicked', () => {
  notification.close()
})

Swiped Right

When the notification has been swiped to the right. This usually indicates that the user wants to dismiss the notification.

const notification = notifier.notify('Calendar')

notification.on('swipedRight', () => {
  notification.close()
})

Button Clicked

When any one of the buttons are clicked, it'll trigger a buttonClicked event, and pass the text, button index and options to the handler.

const notification = notifier.notify('Calendar', {
  buttons: ['Dismiss', 'Snooze'],
  url: "http://google.com"
})

notification.on('buttonClicked', (text, buttonIndex, options) => {
  if (text === 'Snooze') {
    // Snooze!
  } else if(buttonIndex === 1) {
    //open options.url
  }
  notification.close()
})