主进程 main
// main.js
const {app, Notification} = require("electron/main")
app.whenReady().then(() => {
createWindow()
}).then(() => {
new Notification({
title: "Basis Notification",
body: "Notification from main process"
}).show()
})
渲染进程
// renderer.js
new window.Notification("Renderer Notification",{body: "Notification from renderer process"}).onclick = () => {
console.log("Notification clicked")
}