diff --git a/docs-translations/zh-CN/tutorial/online-offline-events.md b/docs-translations/zh-CN/tutorial/online-offline-events.md index e06bb80e89f2..c4ba40ce5b35 100644 --- a/docs-translations/zh-CN/tutorial/online-offline-events.md +++ b/docs-translations/zh-CN/tutorial/online-offline-events.md @@ -1,35 +1,36 @@ # 在线/离线事件探测 使用标准 HTML5 APIs 可以实现在线和离线事件的探测,就像以下例子: -*main.js* -```javascript -const electron = require('electron') -const app = electron.app -const BrowserWindow = electron.BrowserWindow +_main.js_ -var onlineStatusWindow -app.on('ready', function () { +```javascript +const {app, BrowserWindow} = require('electron') + +let onlineStatusWindow + +app.on('ready', () => { onlineStatusWindow = new BrowserWindow({ width: 0, height: 0, show: false }) onlineStatusWindow.loadURL(`file://${__dirname}/online-status.html`) }) ``` -*online-status.html* +_online-status.html_ + ```html - - - + alertOnlineStatus() + + ```