From 5e033cb7f869f42e93c641fcfddba59fa62742f7 Mon Sep 17 00:00:00 2001 From: Jeremy Foster Date: Wed, 26 May 2021 18:18:50 -0700 Subject: [PATCH] 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 --- .../fiddles/features/notifications/main/index.html | 6 +----- docs/fiddles/features/notifications/main/main.js | 14 +++++--------- docs/tutorial/notifications.md | 11 +++++------ 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/docs/fiddles/features/notifications/main/index.html b/docs/fiddles/features/notifications/main/index.html index a3855d2640d8..3c23f9066d9c 100644 --- a/docs/fiddles/features/notifications/main/index.html +++ b/docs/fiddles/features/notifications/main/index.html @@ -7,10 +7,6 @@

Hello World!

-

- We are using node , - Chrome , - and Electron . -

+

After launching this application, you should see the system notification.

diff --git a/docs/fiddles/features/notifications/main/main.js b/docs/fiddles/features/notifications/main/main.js index 2f9dec51e70e..f6e6f867ccc8 100644 --- a/docs/fiddles/features/notifications/main/main.js +++ b/docs/fiddles/features/notifications/main/main.js @@ -3,21 +3,17 @@ const { app, BrowserWindow, Notification } = require('electron') function createWindow () { const win = new BrowserWindow({ width: 800, - height: 600, - webPreferences: { - nodeIntegration: true - } + height: 600 }) win.loadFile('index.html') } +const NOTIFICATION_TITLE = 'Basic Notification' +const NOTIFICATION_BODY = 'Notification from the Main process' + function showNotification () { - const notification = { - title: 'Basic Notification', - body: 'Notification from the Main process' - } - new Notification(notification).show() + new Notification({ title: NOTIFICATION_TITLE, body: NOTIFICATION_BODY }).show() } app.whenReady().then(createWindow).then(showNotification) diff --git a/docs/tutorial/notifications.md b/docs/tutorial/notifications.md index 072e3de9aef9..2ba5abb2b7a5 100644 --- a/docs/tutorial/notifications.md +++ b/docs/tutorial/notifications.md @@ -55,18 +55,17 @@ Starting with a working application from the ```javascript fiddle='docs/fiddles/features/notifications/main' const { Notification } = require('electron') +const NOTIFICATION_TITLE = 'Basic Notification' +const NOTIFICATION_BODY = 'Notification from the Main process' + function showNotification () { - const notification = { - title: 'Basic Notification', - body: 'Notification from the Main process' - } - new Notification(notification).show() + new Notification({ title: NOTIFICATION_TITLE, body: NOTIFICATION_BODY }).show() } 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)