Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
amhoho committed May 23, 2017
1 parent cacec36 commit f0faf88
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## 前言:
> Electron中文文档! 精心翻译,完美排版,实时同步更新! (本文档未经同意不得传播!) , 最后同步:2017-05-20
> Electron中文文档! 精心翻译,完美排版,实时同步更新! (本文档未经同意不得传播!) , 最后同步:2017-05-23
### QQ交流群:
- 群名称:Electron/Nw.js开发交流群
Expand Down
4 changes: 2 additions & 2 deletions api/browser-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ win.on('closed', () => {
})

let view = new BrowserView()
win.addChildView(view)
view.setBounds(0, 0, 300, 300)
win.setBrowserView(view)
view.setBounds({ x: 0, y: 0, width: 300, height: 300 })
view.webContents.loadURL('https://electron.atom.io')
```

Expand Down
2 changes: 1 addition & 1 deletion api/browser-window.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ child.once('ready-to-show',()=> {
* `offscreen` Boolean(可选) - 是否绘制和渲染可视区域外的窗口 [更多细节](../tutorial/offscreen-rendering.md),默认为 `false` .
* `contextIsolation` Boolean (可选) - 是否在独立JavaScript环境中运行Electron API和指定的 `preload`脚本,默认为`false`.该 `preload`脚本仍然可完全访问 `document``window` 全局变量,但它将使用自身内置函数如( `Array`, `Object`, `JSON`等等.) 并且将被加载的页面与对全局环境所做的任何更改隔离开来. 该选项类同[Chrome Content Scripts][chrome-content-scripts],其目的是确保潜在的不受信任内容在加载时无法篡改 `preload`脚本或Electron API. _试验功能_
* `nativeWindowOpen` Boolean (可选) - 是否使用原生默认的 `window.open()`. 默认为 `false`.
* `webviewTag` Boolean (可选) - 是否启用 [`<webview>` tag](webview-tag.md)标签. 默认为上文中 `nodeIntegration`设置的值. **注意:** 您应当确保 `<webview>`中远程或不受信任的内容里不会创建恶意的 `preload` 脚本,因为该脚本将会在执行时集成了Node.不过,您可以使用 [webContents](web-contents.md) 中的 `will-attach-webview` 事件对 `preload` 脚本进行剥离并验证或更改 `<webview>`的初始设置.
* `webviewTag` Boolean (可选) - 是否启用 [`<webview>` tag](webview-tag.md)标签. 默认为上文中 `nodeIntegration`设置的值. **注意:** 您应当确保 `<webview>`中远程或不受信任的内容里不会创建恶意的 `preload` 脚本,因为该脚本将会集成Node.不过,您可以使用 [webContents](web-contents.md) 中的 `will-attach-webview` 事件对 `preload` 脚本进行剥离并验证或更改 `<webview>`的初始设置.

当使用 `minWidth`/ `maxWidth`/ `minHeight`/ `maxHeight`设置最小或最大窗口大小时,它只限制用户.它不会阻止您将不符合大小限制的大小传递给 `setBounds`/ `setSize``BrowserWindow`的构造函数.

Expand Down
5 changes: 4 additions & 1 deletion tutorial/debugging-main-process-vscode.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ $ code electron-quick-start
"request": "launch",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"program": "${workspaceRoot}/main.js"
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"args" : ["."]
}
]
}
Expand Down
19 changes: 19 additions & 0 deletions tutorial/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,24 @@
* WebViews: 不要使用 `disablewebsecurity`
* WebViews: 不要使用 `allowpopups`
* WebViews: 不要使用 `insertCSS``executeJavaScript` 操作远程 CSS/JS.
* WebViews: 在 `will-attach-webview`事件之前,应验证 `<webview>`所有的选项或参数:

```js
app.on('web-contents-created', (event, contents) => {
contents.on('will-attach-webview', (event, webPreferences, params) => {
// 未使用或已验证其位置合法性时剥离预加载脚本
delete webPreferences.preload
delete webPreferences.preloadURL

// 禁止集成Node.
webPreferences.nodeIntegration = false

//验证加载中的URL.
if (!params.src.startsWith('https://yourapp.com/')) {
event.preventDefault()
}
})
})
```

强调一下,这份列表只是将风险降到最低,并不会完全屏蔽风险。 如果您的目的是展示一个网站,浏览器将是一个更安全的选择。

0 comments on commit f0faf88

Please sign in to comment.