electron notification 通知的使用

网友投稿 1082 2022-11-22

electron notification 通知的使用

electron notification 通知的使用

electron notification 通知的使用

electron 的 ​​notification​​ 是走的系统通知通道,Windows上表现为从右边弹出的通知,macOS 为从右上角弹出的通知

一、导入 Notification

const {Notification} = require('electron')

二、新建一个 Notification 实例

在使用通知之前,先要确认系统是否支持 notification,使用 ​​Notification​​​ 静态方法 ​​.isSupported()​​ 来获取是否可用

然后新建一个 ​​Notification​​​ 实例,传递一个配置对象,具体的配置项目看官方文档:​​​通知标题subtitle 副标题​​macOS​​body: 通知内容

最后用当前实例 ​​.show()​​ 显示就好了。

// notification if (Notification.isSupported()){ console.log('notification is suppoerted') new Notification({ title: '已成功导出文件', subtitle: `文件路径:${exportFilePath}`, // macOS body: `文件路径:${exportFilePath}` }).show() }

windows 上的效果就是这样

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:产业互联网中,「小」程序有「大」作为
下一篇:《果然新鲜》电商项目(07)-CentOS操作系统安装
相关文章

 发表评论

暂时没有评论,来抢沙发吧~