Merge pull request #2732 from John-Lin/master
Add doc translation in zh-TW
This commit is contained in:
commit
530b040ade
3 changed files with 92 additions and 0 deletions
28
docs-translations/zh-TW/api/file-object.md
Normal file
28
docs-translations/zh-TW/api/file-object.md
Normal file
|
@ -0,0 +1,28 @@
|
|||
# `File` object
|
||||
|
||||
DOM's File 介面提供一個將本地文件抽象化,並可以讓使用者對本地文件直接使用 HTML5 檔案 API
|
||||
Electron 可以添加一個 `path` 屬性至 `File` 接口進而顯示檔案在檔案系統內的真實路徑。
|
||||
|
||||
範例,獲得一個檔案之真實路徑,將檔案拖拉至應用程式 (dragged-onto-the-app):
|
||||
|
||||
```html
|
||||
<div id="holder">
|
||||
Drag your file here
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var holder = document.getElementById('holder');
|
||||
holder.ondragover = function () {
|
||||
return false;
|
||||
};
|
||||
holder.ondragleave = holder.ondragend = function () {
|
||||
return false;
|
||||
};
|
||||
holder.ondrop = function (e) {
|
||||
e.preventDefault();
|
||||
var file = e.dataTransfer.files[0];
|
||||
console.log('File you dragged here is', file.path);
|
||||
return false;
|
||||
};
|
||||
</script>
|
||||
```
|
23
docs-translations/zh-TW/api/process.md
Normal file
23
docs-translations/zh-TW/api/process.md
Normal file
|
@ -0,0 +1,23 @@
|
|||
# process
|
||||
|
||||
在 Electron 裡的 `process` 物件具有以下幾個與 upstream node 的不同點:
|
||||
|
||||
* `process.type` String - Process 的型態,可以是 `browser` (i.e. 主行程) 或 `renderer`.
|
||||
* `process.versions['electron']` String - Electron 的版本
|
||||
* `process.versions['chrome']` String - Chromium 的版本
|
||||
* `process.resourcesPath` String - JavaScript 源碼的路徑
|
||||
|
||||
# 方法 (Methods)
|
||||
|
||||
`process` 物件具有以下的方法:
|
||||
|
||||
### `process.hang`
|
||||
|
||||
會導致目前行程的主執行緒停住
|
||||
|
||||
## process.setFdLimit(maxDescriptors) _OS X_ _Linux_
|
||||
|
||||
* `maxDescriptors` Integer
|
||||
|
||||
設置文件描述符 (file descriptor) soft limit `maxDescriptors` 或 OS hard
|
||||
limit ,以較低者為準當目前的行程。
|
41
docs-translations/zh-TW/api/synopsis.md
Normal file
41
docs-translations/zh-TW/api/synopsis.md
Normal file
|
@ -0,0 +1,41 @@
|
|||
# Synopsis
|
||||
|
||||
所有的 [Node.js's 內建模組](http://nodejs.org/api/) 都可以在 Electron 使用,而且
|
||||
第三方的 node 模組同樣的全部支援(包含[原生模組](../tutorial/using-native-node-modules.md))
|
||||
|
||||
Electron 也提供一些額外的內建模組用來開發原生桌面應用程式,一些模組只可以使用在主行程上
|
||||
(main process) 一些只可以使用在渲染行程 (renderer process) 上 (網頁) ,另外還有一些
|
||||
模組在兩邊的行程都可以使用。
|
||||
|
||||
基本的規則是: 如果一個模組是 [GUI](https://zh.wikipedia.org/wiki/%E5%9B%BE%E5%BD%A2%E7%94%A8%E6%88%B7%E7%95%8C%E9%9D%A2)
|
||||
或者是 low-level 與系統相關的,那麼它就應該只能在主行程上使用 (main process) 你必須要對熟悉 [main process vs. renderer process](../tutorial/quick-start.md#the-main-process) 的觀念,才能去使用這些模組。
|
||||
|
||||
主行程 (main process) 腳本是一個像一般 Node.js 的腳本:
|
||||
|
||||
```javascript
|
||||
var app = require('app');
|
||||
var BrowserWindow = require('browser-window');
|
||||
|
||||
var window = null;
|
||||
|
||||
app.on('ready', function() {
|
||||
window = new BrowserWindow({width: 800, height: 600});
|
||||
window.loadUrl('https://github.com');
|
||||
});
|
||||
```
|
||||
|
||||
渲染行程 (renderer process) 跟一般正常的網頁沒有差別,而且還能有使用 node 模組的能力:
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
<script>
|
||||
var remote = require('remote');
|
||||
console.log(remote.require('app').getVersion());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
執行你的應用程式,請閱讀[Run your app](../tutorial/quick-start.md#run-your-app).
|
Loading…
Add table
Reference in a new issue