docs: Update notifications (main) docs (#29268)
* remove version info from index.html page * remove nodeIntegration * format code and update readme * add note to user in index.html
This commit is contained in:
parent
36bca3278d
commit
5e033cb7f8
3 changed files with 11 additions and 20 deletions
|
@ -7,10 +7,6 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Hello World!</h1>
|
<h1>Hello World!</h1>
|
||||||
<p>
|
<p>After launching this application, you should see the system notification.</p>
|
||||||
We are using node <script>document.write(process.versions.node)</script>,
|
|
||||||
Chrome <script>document.write(process.versions.chrome)</script>,
|
|
||||||
and Electron <script>document.write(process.versions.electron)</script>.
|
|
||||||
</p>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -3,21 +3,17 @@ const { app, BrowserWindow, Notification } = require('electron')
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
const win = new BrowserWindow({
|
const win = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600
|
||||||
webPreferences: {
|
|
||||||
nodeIntegration: true
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
win.loadFile('index.html')
|
win.loadFile('index.html')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NOTIFICATION_TITLE = 'Basic Notification'
|
||||||
|
const NOTIFICATION_BODY = 'Notification from the Main process'
|
||||||
|
|
||||||
function showNotification () {
|
function showNotification () {
|
||||||
const notification = {
|
new Notification({ title: NOTIFICATION_TITLE, body: NOTIFICATION_BODY }).show()
|
||||||
title: 'Basic Notification',
|
|
||||||
body: 'Notification from the Main process'
|
|
||||||
}
|
|
||||||
new Notification(notification).show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.whenReady().then(createWindow).then(showNotification)
|
app.whenReady().then(createWindow).then(showNotification)
|
||||||
|
|
|
@ -55,18 +55,17 @@ Starting with a working application from the
|
||||||
```javascript fiddle='docs/fiddles/features/notifications/main'
|
```javascript fiddle='docs/fiddles/features/notifications/main'
|
||||||
const { Notification } = require('electron')
|
const { Notification } = require('electron')
|
||||||
|
|
||||||
|
const NOTIFICATION_TITLE = 'Basic Notification'
|
||||||
|
const NOTIFICATION_BODY = 'Notification from the Main process'
|
||||||
|
|
||||||
function showNotification () {
|
function showNotification () {
|
||||||
const notification = {
|
new Notification({ title: NOTIFICATION_TITLE, body: NOTIFICATION_BODY }).show()
|
||||||
title: 'Basic Notification',
|
|
||||||
body: 'Notification from the Main process'
|
|
||||||
}
|
|
||||||
new Notification(notification).show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.whenReady().then(createWindow).then(showNotification)
|
app.whenReady().then(createWindow).then(showNotification)
|
||||||
```
|
```
|
||||||
|
|
||||||
After launching the Electron application, you should see the notification:
|
After launching the Electron application, you should see the system notification:
|
||||||
|
|
||||||
![Notification in the Main process](../images/notification-main.png)
|
![Notification in the Main process](../images/notification-main.png)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue