document process(es) for all APIs
This commit is contained in:
parent
e8bb79310c
commit
ac68de6215
26 changed files with 53 additions and 3 deletions
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Enable apps to automatically update themselves.
|
> Enable apps to automatically update themselves.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process)
|
||||||
|
|
||||||
The `autoUpdater` module provides an interface for the
|
The `autoUpdater` module provides an interface for the
|
||||||
[Squirrel](https://github.com/Squirrel) framework.
|
[Squirrel](https://github.com/Squirrel) framework.
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Create and control browser windows.
|
> Create and control browser windows.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process)
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// In the main process.
|
// In the main process.
|
||||||
const {BrowserWindow} = require('electron')
|
const {BrowserWindow} = require('electron')
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
> Perform copy and paste operations on the system clipboard.
|
> Perform copy and paste operations on the system clipboard.
|
||||||
|
|
||||||
Processes: [Main](../tutorial/quick-start.md#main-process), [Renderer](../tutorial/quick-start.md#renderer-process)
|
Process: [Main](../tutorial/quick-start.md#main-process), [Renderer](../tutorial/quick-start.md#renderer-process)
|
||||||
|
|
||||||
The following example shows how to write a string to the clipboard:
|
The following example shows how to write a string to the clipboard:
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Submit crash reports to a remote server.
|
> Submit crash reports to a remote server.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process), [Renderer](../tutorial/quick-start.md#renderer-process)
|
||||||
|
|
||||||
The following is an example of automatically submitting a crash report to a
|
The following is an example of automatically submitting a crash report to a
|
||||||
remote server:
|
remote server:
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Display native system dialogs for opening and saving files, alerting, etc.
|
> Display native system dialogs for opening and saving files, alerting, etc.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process)
|
||||||
|
|
||||||
An example of showing a dialog to select multiple files and directories:
|
An example of showing a dialog to select multiple files and directories:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Control file downloads from remote sources.
|
> Control file downloads from remote sources.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process)
|
||||||
|
|
||||||
`DownloadItem` is an `EventEmitter` that represents a download item in Electron.
|
`DownloadItem` is an `EventEmitter` that represents a download item in Electron.
|
||||||
It is used in `will-download` event of `Session` class, and allows users to
|
It is used in `will-download` event of `Session` class, and allows users to
|
||||||
control the download item.
|
control the download item.
|
||||||
|
@ -59,7 +61,7 @@ Returns:
|
||||||
* `state` String
|
* `state` String
|
||||||
|
|
||||||
Emitted when the download is in a terminal state. This includes a completed
|
Emitted when the download is in a terminal state. This includes a completed
|
||||||
download, a cancelled download(via `downloadItem.cancel()`), and interrupted
|
download, a cancelled download (via `downloadItem.cancel()`), and interrupted
|
||||||
download that can't be resumed.
|
download that can't be resumed.
|
||||||
|
|
||||||
The `state` can be one of following:
|
The `state` can be one of following:
|
||||||
|
|
|
@ -7,7 +7,7 @@ let users work on native files directly with the HTML5 file API. Electron has
|
||||||
added a `path` attribute to the `File` interface which exposes the file's real
|
added a `path` attribute to the `File` interface which exposes the file's real
|
||||||
path on filesystem.
|
path on filesystem.
|
||||||
|
|
||||||
Example on getting a real path from a dragged-onto-the-app file:
|
Example of getting a real path from a dragged-onto-the-app file:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<div id="holder">
|
<div id="holder">
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Detect keyboard events when the application does not have keyboard focus.
|
> Detect keyboard events when the application does not have keyboard focus.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process)
|
||||||
|
|
||||||
The `globalShortcut` module can register/unregister a global keyboard shortcut
|
The `globalShortcut` module can register/unregister a global keyboard shortcut
|
||||||
with the operating system so that you can customize the operations for various
|
with the operating system so that you can customize the operations for various
|
||||||
shortcuts.
|
shortcuts.
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Communicate asynchronously from the main process to renderer processes.
|
> Communicate asynchronously from the main process to renderer processes.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process)
|
||||||
|
|
||||||
The `ipcMain` module is an instance of the
|
The `ipcMain` module is an instance of the
|
||||||
[EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter) class. When used in the main
|
[EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter) class. When used in the main
|
||||||
process, it handles asynchronous and synchronous messages sent from a renderer
|
process, it handles asynchronous and synchronous messages sent from a renderer
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Communicate asynchronously from a renderer process to the main process.
|
> Communicate asynchronously from a renderer process to the main process.
|
||||||
|
|
||||||
|
Process: [Renderer](../tutorial/quick-start.md#renderer-process)
|
||||||
|
|
||||||
The `ipcRenderer` module is an instance of the
|
The `ipcRenderer` module is an instance of the
|
||||||
[EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter) class. It provides a few
|
[EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter) class. It provides a few
|
||||||
methods so you can send synchronous and asynchronous messages from the render
|
methods so you can send synchronous and asynchronous messages from the render
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Add items to native application menus and context menus.
|
> Add items to native application menus and context menus.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process)
|
||||||
|
|
||||||
See [`Menu`](menu.md) for examples.
|
See [`Menu`](menu.md) for examples.
|
||||||
|
|
||||||
## Class: MenuItem
|
## Class: MenuItem
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Create native application menus and context menus.
|
> Create native application menus and context menus.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process)
|
||||||
|
|
||||||
Each `Menu` consists of multiple [`MenuItem`](menu-item.md)s and each `MenuItem`
|
Each `Menu` consists of multiple [`MenuItem`](menu-item.md)s and each `MenuItem`
|
||||||
can have a submenu.
|
can have a submenu.
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Create tray, dock, and application icons using PNG or JPG files.
|
> Create tray, dock, and application icons using PNG or JPG files.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process), [Renderer](../tutorial/quick-start.md#renderer-process)
|
||||||
|
|
||||||
In Electron, for the APIs that take images, you can pass either file paths or
|
In Electron, for the APIs that take images, you can pass either file paths or
|
||||||
`NativeImage` instances. An empty image will be used when `null` is passed.
|
`NativeImage` instances. An empty image will be used when `null` is passed.
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Issue HTTP/HTTPS requests using Chromium's native networking library
|
> Issue HTTP/HTTPS requests using Chromium's native networking library
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process)
|
||||||
|
|
||||||
The `net` module is a client-side API for issuing HTTP(S) requests. It is
|
The `net` module is a client-side API for issuing HTTP(S) requests. It is
|
||||||
similar to the [HTTP](https://nodejs.org/api/http.html) and
|
similar to the [HTTP](https://nodejs.org/api/http.html) and
|
||||||
[HTTPS](https://nodejs.org/api/https.html) modules of Node.js but uses
|
[HTTPS](https://nodejs.org/api/https.html) modules of Node.js but uses
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Monitor power state changes.
|
> Monitor power state changes.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process)
|
||||||
|
|
||||||
You cannot require or use this module until the `ready` event of the `app`
|
You cannot require or use this module until the `ready` event of the `app`
|
||||||
module is emitted.
|
module is emitted.
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Block the system from entering low-power (sleep) mode.
|
> Block the system from entering low-power (sleep) mode.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process)
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Extensions to process object.
|
> Extensions to process object.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process)
|
||||||
|
|
||||||
The `process` object is extended in Electron with following APIs:
|
The `process` object is extended in Electron with following APIs:
|
||||||
|
|
||||||
## Events
|
## Events
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Register a custom protocol and intercept existing protocol requests.
|
> Register a custom protocol and intercept existing protocol requests.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process)
|
||||||
|
|
||||||
An example of implementing a protocol that has the same effect as the
|
An example of implementing a protocol that has the same effect as the
|
||||||
`file://` protocol:
|
`file://` protocol:
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Use main process modules from the renderer process.
|
> Use main process modules from the renderer process.
|
||||||
|
|
||||||
|
Process: [Renderer](../tutorial/quick-start.md#renderer-process)
|
||||||
|
|
||||||
The `remote` module provides a simple way to do inter-process communication
|
The `remote` module provides a simple way to do inter-process communication
|
||||||
(IPC) between the renderer process (web page) and the main process.
|
(IPC) between the renderer process (web page) and the main process.
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
> Retrieve information about screen size, displays, cursor position, etc.
|
> Retrieve information about screen size, displays, cursor position, etc.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process),
|
||||||
|
[Renderer](../tutorial/quick-start.md#renderer-process)
|
||||||
|
|
||||||
You cannot require or use this module until the `ready` event of the `app`
|
You cannot require or use this module until the `ready` event of the `app`
|
||||||
module is emitted.
|
module is emitted.
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Manage browser sessions, cookies, cache, proxy settings, etc.
|
> Manage browser sessions, cookies, cache, proxy settings, etc.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process)
|
||||||
|
|
||||||
The `session` module can be used to create new `Session` objects.
|
The `session` module can be used to create new `Session` objects.
|
||||||
|
|
||||||
You can also access the `session` of existing pages by using the `session`
|
You can also access the `session` of existing pages by using the `session`
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
> Manage files and URLs using their default applications.
|
> Manage files and URLs using their default applications.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process),
|
||||||
|
[Renderer](../tutorial/quick-start.md#renderer-process)
|
||||||
|
|
||||||
The `shell` module provides functions related to desktop integration.
|
The `shell` module provides functions related to desktop integration.
|
||||||
|
|
||||||
An example of opening a URL in the user's default browser:
|
An example of opening a URL in the user's default browser:
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Get system preferences.
|
> Get system preferences.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process)
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const {systemPreferences} = require('electron')
|
const {systemPreferences} = require('electron')
|
||||||
console.log(systemPreferences.isDarkMode())
|
console.log(systemPreferences.isDarkMode())
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Add icons and context menus to the system's notification area.
|
> Add icons and context menus to the system's notification area.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process)
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const {app, Menu, Tray} = require('electron')
|
const {app, Menu, Tray} = require('electron')
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Render and control web pages.
|
> Render and control web pages.
|
||||||
|
|
||||||
|
Process: [Main](../tutorial/quick-start.md#main-process)
|
||||||
|
|
||||||
`webContents` is an
|
`webContents` is an
|
||||||
[EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter).
|
[EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter).
|
||||||
It is responsible for rendering and controlling a web page and is a property of
|
It is responsible for rendering and controlling a web page and is a property of
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
> Customize the rendering of the current web page.
|
> Customize the rendering of the current web page.
|
||||||
|
|
||||||
|
Process: [Renderer](../tutorial/quick-start.md#renderer-process)
|
||||||
|
|
||||||
An example of zooming current page to 200%.
|
An example of zooming current page to 200%.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
|
Loading…
Reference in a new issue