Electron 通知

主进程 main

主进程通知使用 Electron 的通知模块。使用此模块创建的通知对象不会立刻显示,除非调用他们的 show() 实例方法。

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

app.whenReady().then(() => {
	createWindow()
}).then(() => {
	new Notification({
		title: "Basis Notification",
		body: "Notification from main process"
	}).show()
})

渲染进程

通知可以直接在渲染进程中使用 Web Notifications API 显示。

// renderer.js
new window.Notification("Renderer Notification",{body: "Notification from renderer process"}).onclick = () => {
	console.log("Notification clicked")
}

相关推荐

  1. Electron 通知

    2024-07-16 18:02:02       22 阅读
  2. Electron 进程间通信

    2024-07-16 18:02:02       25 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-16 18:02:02       66 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-16 18:02:02       70 阅读
  3. 在Django里面运行非项目文件

    2024-07-16 18:02:02       57 阅读
  4. Python语言-面向对象

    2024-07-16 18:02:02       68 阅读

热门阅读

  1. Linux的初级简单命令

    2024-07-16 18:02:02       21 阅读
  2. 根据PID查看进程执行路径

    2024-07-16 18:02:02       18 阅读
  3. Airtest的控制手机滑动位置偏差修正方法总结

    2024-07-16 18:02:02       22 阅读
  4. Cuda环境及Pytorch环境安装

    2024-07-16 18:02:02       21 阅读
  5. Window -- redis 服务注册、Mysql 服务注册

    2024-07-16 18:02:02       19 阅读
  6. python安全脚本开发简单思路

    2024-07-16 18:02:02       22 阅读
  7. Qt 实战(7)元对象系统 | 7.3、QMetaObject

    2024-07-16 18:02:02       20 阅读
  8. 交易积累——VR

    2024-07-16 18:02:02       23 阅读