Improve grammar and comments
Improve the grammar and sentence structure of the text and improve the code comments.
This commit is contained in:
parent
c2bfc60a59
commit
4baaf03ac7
1 changed files with 15 additions and 14 deletions
|
@ -4,39 +4,40 @@
|
||||||
|
|
||||||
Electron enables you to create desktop applications with pure JavaScript by providing a runtime with rich native APIs. You could see it as a variant of the io.js runtime which is focused on desktop applications instead of web servers.
|
Electron enables you to create desktop applications with pure JavaScript by providing a runtime with rich native APIs. You could see it as a variant of the io.js runtime which is focused on desktop applications instead of web servers.
|
||||||
|
|
||||||
It doesn't mean Electron is a JavaScript binding to GUI libraries. Instead,
|
This doesn't mean Electron is a JavaScript binding to GUI libraries. Instead,
|
||||||
Electron uses web pages as its GUI, so you could also see it as a minimal
|
Electron uses web pages as its GUI, so you could also see it as a minimal
|
||||||
Chromium browser, controlled by JavaScript.
|
Chromium browser, controlled by JavaScript.
|
||||||
|
|
||||||
### Main process
|
### Main process
|
||||||
|
|
||||||
In Electron, the process that runs `package.json`'s `main` script is called
|
In Electron, the process that runs `package.json`'s `main` script is called
|
||||||
__the main process__. The script that runs in the main process, can display GUI by
|
__the main process__. The script that runs in the main process can display a GUI by
|
||||||
creating web pages.
|
creating web pages.
|
||||||
|
|
||||||
### Renderer process
|
### Renderer process
|
||||||
|
|
||||||
Since Electron uses Chromium for displaying web pages, Chromium's
|
Since Electron uses Chromium for displaying web pages, Chromium's
|
||||||
multi-processes architecture is also used. Each web page in Electron runs in
|
multi-process architecture is also used. Each web page in Electron runs in
|
||||||
its own process, which is called __the renderer process__.
|
its own process, which is called __the renderer process__.
|
||||||
|
|
||||||
In normal browsers web pages usually run in a sandboxed environment and are not
|
In normal browsers, web pages usually run in a sandboxed environment and are not
|
||||||
allowed access to native resources. Electron users however, have the power to use
|
allowed access to native resources. Electron users, however, have the power to use
|
||||||
io.js APIs in web pages allowing lower level operating system interactions.
|
io.js APIs in web pages allowing lower level operating system interactions.
|
||||||
|
|
||||||
### Differences between main process and renderer process
|
### Differences between main process and renderer process
|
||||||
|
|
||||||
The main process creates web pages by creating `BrowserWindow` instances. Each `BrowserWindow` instance runs the web page in its own renderer process. When a `BrowserWindow` instance is destroyed, the corresponding renderer process
|
The main process creates web pages by creating `BrowserWindow` instances. Each `BrowserWindow` instance runs the web page in its own renderer process. When a `BrowserWindow` instance is destroyed, the corresponding renderer process
|
||||||
would also be terminated.
|
is also terminated.
|
||||||
|
|
||||||
The main process manages all web pages and their corresponding renderer
|
The main process manages all web pages and their corresponding renderer
|
||||||
processes, each renderer process is isolated and only cares
|
processes. Each renderer process is isolated and only cares
|
||||||
about the web page running in it.
|
about the web page running in it.
|
||||||
|
|
||||||
In web pages, it is not allowed to call native GUI related APIs because managing
|
In web pages, it is not allowed to call native GUI related APIs because managing
|
||||||
native GUI resources in web pages is very dangerous and easy to leak resources.
|
native GUI resources in web pages is very dangerous and it is easy to leak resources.
|
||||||
If you want to do GUI operations in web pages, you have to communicate with
|
If you want to perform GUI operations in a web page, the renderer process of the web
|
||||||
the main process to do it there.
|
page must communicate with the main process to request the main process perform those
|
||||||
|
operations.
|
||||||
|
|
||||||
In Electron, we have provided the [ipc](../api/ipc-renderer.md) module for
|
In Electron, we have provided the [ipc](../api/ipc-renderer.md) module for
|
||||||
communication between main process and renderer process. And there is also a
|
communication between main process and renderer process. And there is also a
|
||||||
|
@ -77,20 +78,20 @@ var BrowserWindow = require('browser-window'); // Module to create native brows
|
||||||
require('crash-reporter').start();
|
require('crash-reporter').start();
|
||||||
|
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
// be closed automatically when the javascript object is GCed.
|
// be closed automatically when the JavaScript object is GCed.
|
||||||
var mainWindow = null;
|
var mainWindow = null;
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
app.on('window-all-closed', function() {
|
app.on('window-all-closed', function() {
|
||||||
// On OSX it is common for applications and their menu bar
|
// On OS X it is common for applications and their menu bar
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
// to stay active until the user quits explicitly with Cmd + Q
|
||||||
if (process.platform != 'darwin') {
|
if (process.platform != 'darwin') {
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// This method will be called when Electron has done everything
|
// This method will be called when Electron has finished
|
||||||
// initialization and ready for creating browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
app.on('ready', function() {
|
app.on('ready', function() {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({width: 800, height: 600});
|
mainWindow = new BrowserWindow({width: 800, height: 600});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue