Merge branch 'master' of https://github.com/NKMR6194/electron into NKMR6194-master

This commit is contained in:
Cheng Zhao 2015-04-20 19:40:04 +08:00
commit fc3026dcfe

View file

@ -2,29 +2,29 @@
## Introduction
Generally, atom-shell enables you to create desktop applications with pure
Generally, 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 atom-shell is a JavaScript binding to GUI libraries. Instead,
atom-shell uses web pages as its GUI, so you could also see it as a minimal
It 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
Chromium browser, controlled by JavaScript.
### The main process
In atom-shell 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 runs in the main process can display GUI by
creating web pages.
### The renderer process
Since atom-shell uses Chromium for displaying web pages, Chromium's
multi-processes architecture is also used. Each web page in atom-shell runs in
Since Electron uses Chromium for displaying web pages, Chromium's
multi-processes architecture is also used. Each web page in Electron runs in
its own process, which is called __the renderer process__.
In normal browsers web pages usually run in a sandboxed environment and are not
allowed access to native resources. In atom-shell users have the power to use
allowed access to native resources. In Electron users have the power to use
io.js APIs in web pages and it is therefore possible to interact with low level
operating system features.
@ -44,14 +44,13 @@ native GUI resources in web pages is very dangerous and easy to leak resources.
If you want to do GUI operations in web pages, you have to communicate with
the main process to do it there.
In atom-shell, 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
[remote](../api/remote.md) module for RPC style communication.
## Write your first atom-shell app
## Write your first Electron app
Generally, an atom-shell app would be structured like this (see the
[hello-atom](https://github.com/dougnukem/hello-atom) repo for reference):
Generally, an Electron app would be structured like this:
```text
your-app/
@ -93,7 +92,7 @@ app.on('window-all-closed', function() {
app.quit();
});
// This method will be called when atom-shell has done everything
// This method will be called when Electron has done everything
// initialization and ready for creating browser windows.
app.on('ready', function() {
// Create the browser window.
@ -123,7 +122,7 @@ Finally the `index.html` is the web page you want to show:
<body>
<h1>Hello World!</h1>
We are using node.js <script>document.write(process.version)</script>
and atom-shell <script>document.write(process.versions['electron'])</script>.
and Electron <script>document.write(process.versions['electron'])</script>.
</body>
</html>
```
@ -133,18 +132,18 @@ Finally the `index.html` is the web page you want to show:
After you're done writing your app, you can create a distribution by
following the [Application distribution](./application-distribution.md) guide
and then execute the packaged app. You can also just use the downloaded
atom-shell binary to execute your app directly.
Electron binary to execute your app directly.
On Windows:
```cmd
$ .\atom-shell\atom.exe your-app\
$ .\electron\electron.exe your-app\
```
On Linux:
```bash
$ ./atom-shell/atom your-app/
$ ./electron/electron your-app/
```
On OS X:
@ -153,5 +152,5 @@ On OS X:
$ ./Electron.app/Contents/MacOS/Atom your-app/
```
`Electron.app` here is part of the atom-shell's release package, you can download
`Electron.app` here is part of the Electron's release package, you can download
it from [here](https://github.com/atom/electron/releases).