Merge remote-tracking branch 'atom/master'
This commit is contained in:
commit
ba7ddd66a1
8 changed files with 179 additions and 40 deletions
|
@ -48,6 +48,7 @@ contains documents describing how to build and contribute to Electron.
|
||||||
- [Korean](https://github.com/atom/electron/tree/master/docs-translations/ko)
|
- [Korean](https://github.com/atom/electron/tree/master/docs-translations/ko)
|
||||||
- [Japanese](https://github.com/atom/electron/tree/master/docs-translations/jp)
|
- [Japanese](https://github.com/atom/electron/tree/master/docs-translations/jp)
|
||||||
- [Spanish](https://github.com/atom/electron/tree/master/docs-translations/es)
|
- [Spanish](https://github.com/atom/electron/tree/master/docs-translations/es)
|
||||||
|
- [Simplified Chinese](https://github.com/atom/electron/tree/master/docs-translations/zh-CN)
|
||||||
|
|
||||||
## Community
|
## Community
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "atom/common/chrome_version.h"
|
#include "atom/common/chrome_version.h"
|
||||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "base/process/process_metrics.h"
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
|
|
||||||
#include "atom/common/node_includes.h"
|
#include "atom/common/node_includes.h"
|
||||||
|
@ -61,6 +62,9 @@ void AtomBindings::BindTo(v8::Isolate* isolate,
|
||||||
dict.SetMethod("crash", &Crash);
|
dict.SetMethod("crash", &Crash);
|
||||||
dict.SetMethod("hang", &Hang);
|
dict.SetMethod("hang", &Hang);
|
||||||
dict.SetMethod("log", &Log);
|
dict.SetMethod("log", &Log);
|
||||||
|
#if defined(OS_POSIX)
|
||||||
|
dict.SetMethod("setFdLimit", &base::SetFdLimit);
|
||||||
|
#endif
|
||||||
dict.SetMethod("activateUvLoop",
|
dict.SetMethod("activateUvLoop",
|
||||||
base::Bind(&AtomBindings::ActivateUVLoop, base::Unretained(this)));
|
base::Bind(&AtomBindings::ActivateUVLoop, base::Unretained(this)));
|
||||||
|
|
||||||
|
|
70
docs-translations/zh-CN/README.md
Normal file
70
docs-translations/zh-CN/README.md
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
## 向导
|
||||||
|
|
||||||
|
* [应用部署](tutorial/application-distribution.md)
|
||||||
|
* [应用打包](tutorial/application-packaging.md)
|
||||||
|
* [使用原生模块](tutorial/using-native-node-modules.md)
|
||||||
|
* [主进程调试](tutorial/debugging-main-process.md)
|
||||||
|
* [使用 Selenium 和 WebDriver](tutorial/using-selenium-and-webdriver.md)
|
||||||
|
* [调试工具扩展](tutorial/devtools-extension.md)
|
||||||
|
* [使用 PepperFlash 插件](tutorial/using-pepper-flash-plugin.md)
|
||||||
|
|
||||||
|
## 教程
|
||||||
|
|
||||||
|
* [快速入门](tutorial/quick-start.md)
|
||||||
|
* [桌面环境集成](tutorial/desktop-environment-integration.md)
|
||||||
|
* [在线/离线事件探测](tutorial/online-offline-events.md)
|
||||||
|
|
||||||
|
## API文档
|
||||||
|
|
||||||
|
* [简介](api/synopsis.md)
|
||||||
|
* [进程对象](api/process.md)
|
||||||
|
* [支持的Chrome命令行开关](api/chrome-command-line-switches.md)
|
||||||
|
|
||||||
|
定制的DOM元素:
|
||||||
|
|
||||||
|
* [`File`对象](api/file-object.md)
|
||||||
|
* [`<webview>`标签](api/web-view-tag.md)
|
||||||
|
* [`window.open`函数](api/window-open.md)
|
||||||
|
|
||||||
|
主进程可用的模块:
|
||||||
|
|
||||||
|
* [app](api/app.md)
|
||||||
|
* [auto-updater](api/auto-updater.md)
|
||||||
|
* [browser-window](api/browser-window.md)
|
||||||
|
* [content-tracing](api/content-tracing.md)
|
||||||
|
* [dialog](api/dialog.md)
|
||||||
|
* [global-shortcut](api/global-shortcut.md)
|
||||||
|
* [ipc (main process)](api/ipc-main-process.md)
|
||||||
|
* [menu](api/menu.md)
|
||||||
|
* [menu-item](api/menu-item.md)
|
||||||
|
* [power-monitor](api/power-monitor.md)
|
||||||
|
* [power-save-blocker](api/power-save-blocker.md)
|
||||||
|
* [protocol](api/protocol.md)
|
||||||
|
* [session](api/session.md)
|
||||||
|
* [webContents](api/web-contents.md)
|
||||||
|
* [tray](api/tray.md)
|
||||||
|
|
||||||
|
渲染进程(网页)可用的模块:
|
||||||
|
|
||||||
|
* [ipc (renderer)](api/ipc-renderer.md)
|
||||||
|
* [remote](api/remote.md)
|
||||||
|
* [web-frame](api/web-frame.md)
|
||||||
|
|
||||||
|
两种进程都可用的模块:
|
||||||
|
|
||||||
|
* [clipboard](api/clipboard.md)
|
||||||
|
* [crash-reporter](api/crash-reporter.md)
|
||||||
|
* [native-image](api/native-image.md)
|
||||||
|
* [screen](api/screen.md)
|
||||||
|
* [shell](api/shell.md)
|
||||||
|
|
||||||
|
## 开发
|
||||||
|
|
||||||
|
* [编码规范](development/coding-style.md)
|
||||||
|
* [源码文件结构](development/source-code-directory-structure.md)
|
||||||
|
* [与 NW.js (原名 node-webkit) 在技术上的差异](development/atom-shell-vs-node-webkit.md)
|
||||||
|
* [构建系统概况](development/build-system-overview.md)
|
||||||
|
* [构建步骤 (Mac)](development/build-instructions-mac.md)
|
||||||
|
* [构建步骤 (Windows)](development/build-instructions-windows.md)
|
||||||
|
* [构建步骤 (Linux)](development/build-instructions-linux.md)
|
||||||
|
* [在调试中使用 SymbolServer](development/setting-up-symbol-server.md)
|
|
@ -269,7 +269,6 @@ Adds `tasks` to the [Tasks][tasks] category of the JumpList on Windows.
|
||||||
consists of two or more icons, set this value to identify the icon. If an
|
consists of two or more icons, set this value to identify the icon. If an
|
||||||
icon file consists of one icon, this value is 0.
|
icon file consists of one icon, this value is 0.
|
||||||
|
|
||||||
|
|
||||||
### `app.commandLine.appendSwitch(switch[, value])`
|
### `app.commandLine.appendSwitch(switch[, value])`
|
||||||
|
|
||||||
Append a switch (with optional `value`) to Chromium's command line.
|
Append a switch (with optional `value`) to Chromium's command line.
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
# global-shortcut
|
# global-shortcut
|
||||||
|
|
||||||
The `global-shortcut` module can register/unregister a global keyboard shortcut
|
The `global-shortcut` module can register/unregister a global keyboard shortcut
|
||||||
with the operating system, so that you can customize the operations for various shortcuts.
|
with the operating system so that you can customize the operations for various
|
||||||
Note that the shortcut is global; it will work even if the app does not have the keyboard focus.
|
shortcuts.
|
||||||
You should not use this module until the `ready` event of the app module is emitted.
|
|
||||||
|
**Note**: The shortcut is global; it will work even if the app does
|
||||||
|
not have the keyboard focus. You should not use this module until the `ready`
|
||||||
|
event of the app module is emitted.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var app = require('app');
|
var app = require('app');
|
||||||
|
@ -32,7 +35,11 @@ app.on('will-quit', function() {
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
## globalShortcut.register(accelerator, callback)
|
## Methods
|
||||||
|
|
||||||
|
The `global-shortcut` module has the following methods:
|
||||||
|
|
||||||
|
### `globalShortcut.register(accelerator, callback)`
|
||||||
|
|
||||||
* `accelerator` [Accelerator](accelerator.md)
|
* `accelerator` [Accelerator](accelerator.md)
|
||||||
* `callback` Function
|
* `callback` Function
|
||||||
|
@ -40,18 +47,19 @@ app.on('will-quit', function() {
|
||||||
Registers a global shortcut of `accelerator`. The `callback` is called when
|
Registers a global shortcut of `accelerator`. The `callback` is called when
|
||||||
the registered shortcut is pressed by the user.
|
the registered shortcut is pressed by the user.
|
||||||
|
|
||||||
## globalShortcut.isRegistered(accelerator)
|
### `globalShortcut.isRegistered(accelerator)`
|
||||||
|
|
||||||
* `accelerator` [Accelerator](accelerator.md)
|
* `accelerator` [Accelerator](accelerator.md)
|
||||||
|
|
||||||
Returns `true` or `false` depending on whether the shortcut `accelerator` is registered.
|
Returns `true` or `false` depending on whether the shortcut `accelerator` is
|
||||||
|
registered.
|
||||||
|
|
||||||
## globalShortcut.unregister(accelerator)
|
### `globalShortcut.unregister(accelerator)`
|
||||||
|
|
||||||
* `accelerator` [Accelerator](accelerator.md)
|
* `accelerator` [Accelerator](accelerator.md)
|
||||||
|
|
||||||
Unregisters the global shortcut of `keycode`.
|
Unregisters the global shortcut of `accelerator`.
|
||||||
|
|
||||||
## globalShortcut.unregisterAll()
|
### `globalShortcut.unregisterAll()`
|
||||||
|
|
||||||
Unregisters all the global shortcuts.
|
Unregisters all the global shortcuts.
|
||||||
|
|
|
@ -1,17 +1,22 @@
|
||||||
# ipc (main process)
|
# ipc (main process)
|
||||||
|
|
||||||
Handles asynchronous and synchronous message sent from a renderer process (web
|
The `ipc` module, when used in the main process, handles asynchronous and
|
||||||
page).
|
synchronous messages sent from a renderer process (web page). Messages sent from
|
||||||
|
a renderer will be emitted to this module.
|
||||||
|
|
||||||
The messages sent from a renderer would be emitted to this module, the event name
|
## Sending Messages
|
||||||
is the `channel` when sending message. To reply a synchronous message, you need
|
|
||||||
to set `event.returnValue`, to send an asynchronous back to the sender, you can
|
|
||||||
use `event.sender.send(...)`.
|
|
||||||
|
|
||||||
It's also possible to send messages from main process to the renderer process,
|
It is also possible to send messages from the main process to the renderer
|
||||||
see [WebContents.send](browser-window.md#webcontentssendchannel-args) for more.
|
process, see [WebContents.send](browser-window.md#webcontentssendchannel-args)
|
||||||
|
for more information.
|
||||||
|
|
||||||
An example of sending and handling messages:
|
- When sending a message, the event name is the `channel`.
|
||||||
|
- To reply a synchronous message, you need to set `event.returnValue`.
|
||||||
|
- To send an asynchronous back to the sender, you can use
|
||||||
|
`event.sender.send(...)`.
|
||||||
|
|
||||||
|
An example of sending and handling messages between the render and main
|
||||||
|
processes:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// In main process.
|
// In main process.
|
||||||
|
@ -38,12 +43,34 @@ ipc.on('asynchronous-reply', function(arg) {
|
||||||
ipc.send('asynchronous-message', 'ping');
|
ipc.send('asynchronous-message', 'ping');
|
||||||
```
|
```
|
||||||
|
|
||||||
## Class: Event
|
## Listening for Messages
|
||||||
|
|
||||||
### Event.returnValue
|
The `ipc` module has the following method to listen for events:
|
||||||
|
|
||||||
Assign to this to return an value to synchronous messages.
|
### `ipc.on(channel, callback)`
|
||||||
|
|
||||||
### Event.sender
|
* `channel` String - The event name.
|
||||||
|
* `callback` Function
|
||||||
|
|
||||||
The `WebContents` that sent the message.
|
When the event occurs the `callback` is called with an `event` object and a
|
||||||
|
message, `arg`.
|
||||||
|
|
||||||
|
## IPC Events
|
||||||
|
|
||||||
|
The `event` object passed to the `callback` has the following methods:
|
||||||
|
|
||||||
|
### `Event.returnValue`
|
||||||
|
|
||||||
|
Set this to the value to be returned in a synchronous message.
|
||||||
|
|
||||||
|
### `Event.sender`
|
||||||
|
|
||||||
|
Returns the `WebContents` that sent the message.
|
||||||
|
|
||||||
|
### `Event.sender.send(channel[, arg1][, arg2][, ...])`
|
||||||
|
|
||||||
|
* `channel` String - The event name.
|
||||||
|
* `arg` (optional)
|
||||||
|
|
||||||
|
This sends an asynchronous message back to the render process. Optionally, there
|
||||||
|
can be one or a series of arguments, `arg`, which can have any type.
|
||||||
|
|
|
@ -1,29 +1,52 @@
|
||||||
# ipc (renderer)
|
# ipc (renderer)
|
||||||
|
|
||||||
The `ipc` module provides a few methods so you can send synchronous and
|
The `ipc` module provides a few methods so you can send synchronous and
|
||||||
asynchronous messages to the main process, and also receive messages sent from
|
asynchronous messages from the render process (web page) to the main process.
|
||||||
main process. If you want to make use of modules of main process from renderer
|
You can also receive replies from the main process.
|
||||||
|
|
||||||
|
**Note**: If you want to make use of modules in the main process from the renderer
|
||||||
process, you might consider using the [remote](remote.md) module.
|
process, you might consider using the [remote](remote.md) module.
|
||||||
|
|
||||||
See [ipc (main process)](ipc-main-process.md) for examples.
|
See [ipc (main process)](ipc-main-process.md) for code examples.
|
||||||
|
|
||||||
## ipc.send(channel[, args...])
|
## Methods
|
||||||
|
|
||||||
Send `args..` to the renderer via `channel` in asynchronous message, the main
|
The `ipc` module has the following methods for sending messages:
|
||||||
process can handle it by listening to the `channel` event of `ipc` module.
|
|
||||||
|
|
||||||
## ipc.sendSync(channel[, args...])
|
**Note**: When using these methods to send a `message` you must also listen
|
||||||
|
for it in the main process with [`ipc (main process)`](ipc-main-process.md).
|
||||||
|
|
||||||
Send `args..` to the renderer via `channel` in synchronous message, and returns
|
### `ipc.send(channel[, arg1][, arg2][, ...])`
|
||||||
the result sent from main process. The main process can handle it by listening to
|
|
||||||
the `channel` event of `ipc` module, and returns by setting `event.returnValue`.
|
|
||||||
|
|
||||||
**Note:** Usually developers should never use this API, since sending
|
* `channel` String - The event name.
|
||||||
synchronous message would block the whole renderer process.
|
* `arg` (optional)
|
||||||
|
|
||||||
## ipc.sendToHost(channel[, args...])
|
Send an event to the main process asynchronously via a `channel`. Optionally,
|
||||||
|
there can be a message: one or a series of arguments, `arg`, which can have any
|
||||||
|
type. The main process handles it by listening for the `channel` event with
|
||||||
|
`ipc`.
|
||||||
|
|
||||||
Like `ipc.send` but the message will be sent to the host page instead of the
|
### `ipc.sendSync(channel[, arg1][, arg2][, ...])`
|
||||||
main process.
|
|
||||||
|
|
||||||
This is mainly used by the page in `<webview>` to communicate with host page.
|
* `channel` String - The event name.
|
||||||
|
* `arg` (optional)
|
||||||
|
|
||||||
|
Send an event to the main process synchronously via a `channel`. Optionally,
|
||||||
|
there can be a message: one or a series of arguments, `arg`, which can have any
|
||||||
|
type. The main process handles it by listening for the `channel` event with
|
||||||
|
`ipc`.
|
||||||
|
|
||||||
|
The main process handles it by listening for the `channel` event with `ipc` and
|
||||||
|
replies by setting the `event.returnValue`.
|
||||||
|
|
||||||
|
**Note:** Sending a synchronous message will block the whole renderer process so
|
||||||
|
using this method is not recommended.
|
||||||
|
|
||||||
|
### `ipc.sendToHost(channel[, arg1][, arg2][, ...])`
|
||||||
|
|
||||||
|
* `channel` String - The event name.
|
||||||
|
* `arg` (optional)
|
||||||
|
|
||||||
|
Like `ipc.send` but the event will be sent to the host page in a `<webview>`
|
||||||
|
instead of the main process. Optionally, there can be a message: one or a series
|
||||||
|
of arguments, `arg`, which can have any type.
|
||||||
|
|
|
@ -11,3 +11,10 @@ upstream node:
|
||||||
## process.hang
|
## process.hang
|
||||||
|
|
||||||
Causes the main thread of the current process hang.
|
Causes the main thread of the current process hang.
|
||||||
|
|
||||||
|
## process.setFdLimit(maxDescriptors) _OS X_ _Linux_
|
||||||
|
|
||||||
|
* `maxDescriptors` Integer
|
||||||
|
|
||||||
|
Sets the file descriptor soft limit to `maxDescriptors` or the OS hard
|
||||||
|
limit, whichever is lower for the current process.
|
||||||
|
|
Loading…
Reference in a new issue