From e2bb8088d4dd3e1bd0a42c30d70e58c49ffc1ca1 Mon Sep 17 00:00:00 2001 From: longbotao Date: Mon, 19 Dec 2016 15:01:50 +0800 Subject: [PATCH] [ci skip]update electron-faq.md in Simplified Chinese docs and fix a little words --- docs-translations/zh-CN/README.md | 4 ++-- docs-translations/zh-CN/faq/electron-faq.md | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/docs-translations/zh-CN/README.md b/docs-translations/zh-CN/README.md index c0116dcd349a5..e46ce19c2a000 100644 --- a/docs-translations/zh-CN/README.md +++ b/docs-translations/zh-CN/README.md @@ -6,7 +6,7 @@ 这里是一些被经常问到的问题,再提 issue 之前请先看一下这里。 -+ [Electron 常见问题](faq/electron-faq.md) 需要更新 ++ [Electron 常见问题](faq/electron-faq.md) ## 向导 @@ -83,7 +83,7 @@ ## 开发 * [代码规范](development/coding-style.md) -* [在 C++ 代码中试用 clang格式化工具](development/clang-format.md) 未翻译 +* [在 C++ 代码中使用 clang格式化工具](development/clang-format.md) 未翻译 * [源码目录结构](development/source-code-directory-structure.md) * [与 NW.js(原 node-webkit)在技术上的差异](development/atom-shell-vs-node-webkit.md) * [构建系统概览](development/build-system-overview.md) diff --git a/docs-translations/zh-CN/faq/electron-faq.md b/docs-translations/zh-CN/faq/electron-faq.md index d898fcc3d0f41..092bc1d8ac12c 100644 --- a/docs-translations/zh-CN/faq/electron-faq.md +++ b/docs-translations/zh-CN/faq/electron-faq.md @@ -16,7 +16,7 @@ Node.js 的新特性通常是由新版本的 V8 带来的。由于 Electron 使 ## 如何在两个网页间共享数据? -在两个网页(渲染进程)间共享数据最简单的方法是使用浏览器中已经实现的 HTML5 API,比较好的方案是用 [Storage API][storage], +在两个网页(渲染进程)间共享数据最简单的方法是使用浏览器中已经实现的 HTML5 API,其中比较好的方案是用 [Storage API][storage], [`localStorage`][local-storage],[`sessionStorage`][session-storage] 或者 [IndexedDB][indexed-db]。 你还可以用 Electron 内的 IPC 机制实现。将数据存在主进程的某个全局变量中,然后在多个渲染进程中使用 `remote` 模块来访问它。 @@ -30,12 +30,12 @@ global.sharedObject = { ```javascript // 在第一个页面中 -require('remote').getGlobal('sharedObject').someProperty = 'new value' +require('electron').remote.getGlobal('sharedObject').someProperty = 'new value' ``` ```javascript // 在第二个页面中 -console.log(require('remote').getGlobal('sharedObject').someProperty) +console.log(require('electron').remote.getGlobal('sharedObject').someProperty) ``` ## 为什么应用的窗口、托盘在一段时间后不见了? @@ -52,17 +52,21 @@ console.log(require('remote').getGlobal('sharedObject').someProperty) 从 ```javascript -app.on('ready', function () { - var tray = new Tray('/path/to/icon.png') +const {app, Tray} = require('electron') +app.on('ready', () => { + const tray = new Tray('/path/to/icon.png') + tray.setTitle('hello world') }) ``` 改为 ```javascript -var tray = null -app.on('ready', function () { +const {app, Tray} = require('electron') +let tray = null +app.on('ready', () => { tray = new Tray('/path/to/icon.png') + tray.setTitle('hello world') }) ```