add content-tracing && update browser-window
This commit is contained in:
parent
0ec7f35c24
commit
d25d1f3f8b
2 changed files with 152 additions and 27 deletions
|
@ -258,11 +258,11 @@ someWindow.on('app-command', function(e, cmd) {
|
|||
|
||||
### `BrowserWindow.getAllWindows()`
|
||||
|
||||
返回一个所有已经打开了的窗口的对象数组.
|
||||
返回一个所有已经打开了窗口的对象数组.
|
||||
|
||||
### `BrowserWindow.getFocusedWindow()`
|
||||
|
||||
返回应用当前聚焦窗口,如果没有就返回 `null`.
|
||||
返回应用当前获得焦点窗口,如果没有就返回 `null`.
|
||||
|
||||
### `BrowserWindow.fromWebContents(webContents)`
|
||||
|
||||
|
@ -325,19 +325,19 @@ var win = new BrowserWindow({ width: 800, height: 600 });
|
|||
|
||||
### `win.focus()`
|
||||
|
||||
聚焦窗口.
|
||||
窗口获得焦点.
|
||||
|
||||
### `win.isFocused()`
|
||||
|
||||
返回 boolean, 窗口是否聚焦.
|
||||
返回 boolean, 窗口是否获得焦点.
|
||||
|
||||
### `win.show()`
|
||||
|
||||
展示并且聚焦窗口.
|
||||
展示并且使窗口获得焦点.
|
||||
|
||||
### `win.showInactive()`
|
||||
|
||||
展示窗口但是不聚焦.
|
||||
展示窗口但是不获得焦点.
|
||||
|
||||
### `win.hide()`
|
||||
|
||||
|
@ -462,7 +462,7 @@ var win = new BrowserWindow({ width: 800, height: 600 });
|
|||
|
||||
### `win.isResizable()`
|
||||
|
||||
返回窗口是否可以被用户改变size的状态.
|
||||
返回 boolean,窗口是否可以被用户改变size.
|
||||
|
||||
### `win.setMovable(movable)` _OS X_ _Windows_
|
||||
|
||||
|
@ -472,7 +472,7 @@ var win = new BrowserWindow({ width: 800, height: 600 });
|
|||
|
||||
### `win.isMovable()` _OS X_ _Windows_
|
||||
|
||||
返回窗口是否可以被用户拖动的状态. Linux 总是返回 `true`.
|
||||
返回 boolean,窗口是否可以被用户拖动. Linux 总是返回 `true`.
|
||||
|
||||
### `win.setMinimizable(minimizable)` _OS X_ _Windows_
|
||||
|
||||
|
@ -482,7 +482,7 @@ var win = new BrowserWindow({ width: 800, height: 600 });
|
|||
|
||||
### `win.isMinimizable()` _OS X_ _Windows_
|
||||
|
||||
返回窗口是否可以最小化的状态. Linux 总是返回 `true`.
|
||||
返回 boolean,窗口是否可以最小化. Linux 总是返回 `true`.
|
||||
|
||||
### `win.setMaximizable(maximizable)` _OS X_ _Windows_
|
||||
|
||||
|
@ -492,7 +492,7 @@ var win = new BrowserWindow({ width: 800, height: 600 });
|
|||
|
||||
### `win.isMaximizable()` _OS X_ _Windows_
|
||||
|
||||
返回窗口是否可以最大化的状态. Linux 总是返回 `true`.
|
||||
返回 boolean,窗口是否可以最大化. Linux 总是返回 `true`.
|
||||
|
||||
### `win.setFullScreenable(fullscreenable)`
|
||||
|
||||
|
@ -502,7 +502,7 @@ var win = new BrowserWindow({ width: 800, height: 600 });
|
|||
|
||||
### `win.isFullScreenable()`
|
||||
|
||||
返回点击最大化按钮是否可以全屏或最大化窗口的状态.
|
||||
返回 boolean,点击最大化按钮是否可以全屏或最大化窗口.
|
||||
|
||||
### `win.setClosable(closable)` _OS X_ _Windows_
|
||||
|
||||
|
@ -512,17 +512,17 @@ var win = new BrowserWindow({ width: 800, height: 600 });
|
|||
|
||||
### `win.isClosable()` _OS X_ _Windows_
|
||||
|
||||
返回窗口是否可以人为关闭的状态. Linux 总是返回 `true`.
|
||||
返回 boolean,窗口是否可以人为关闭. Linux 总是返回 `true`.
|
||||
|
||||
### `win.setAlwaysOnTop(flag)`
|
||||
|
||||
* `flag` Boolean
|
||||
|
||||
是否设置这个窗口始终在其他窗口之上.设置之后,这个窗口仍然是一个普通的窗口,不是一个不可以聚焦的工具箱窗口.
|
||||
是否设置这个窗口始终在其他窗口之上.设置之后,这个窗口仍然是一个普通的窗口,不是一个不可以获得焦点的工具箱窗口.
|
||||
|
||||
### `win.isAlwaysOnTop()`
|
||||
|
||||
返回当前窗口是否始终在其它窗口之前的状态.
|
||||
返回 boolean,当前窗口是否始终在其它窗口之前.
|
||||
|
||||
### `win.center()`
|
||||
|
||||
|
@ -572,7 +572,7 @@ var win = new BrowserWindow({ width: 800, height: 600 });
|
|||
|
||||
### `win.isKiosk()`
|
||||
|
||||
返回是否进入或离开 kiosk 模式的状态.
|
||||
返回 boolean,是否进入或离开 kiosk 模式.
|
||||
|
||||
### `win.getNativeWindowHandle()`
|
||||
|
||||
|
@ -621,7 +621,7 @@ windows上句柄类型为 `HWND` ,OS X `NSView*` , Linux `Window`.
|
|||
|
||||
### `win.isDocumentEdited()` _OS X_
|
||||
|
||||
返回当前窗口文档是否可编辑状态.
|
||||
返回 boolean,当前窗口文档是否可编辑.
|
||||
|
||||
### `win.focusOnWebView()`
|
||||
|
||||
|
@ -673,14 +673,10 @@ windows上句柄类型为 `HWND` ,OS X `NSView*` , Linux `Window`.
|
|||
|
||||
### `win.setOverlayIcon(overlay, description)` _Windows 7+_
|
||||
|
||||
* `overlay` [NativeImage](native-image.md) - the icon to display on the bottom
|
||||
right corner of the taskbar icon. If this parameter is `null`, the overlay is
|
||||
cleared
|
||||
* `description` String - a description that will be provided to Accessibility
|
||||
screen readers
|
||||
* `overlay` [NativeImage](native-image.md) - 在底部任务栏右边显示图标.
|
||||
* `description` String - 描述.
|
||||
|
||||
Sets a 16 x 16 pixel overlay onto the current taskbar icon, usually used to convey some
|
||||
sort of application status or to passively notify the user.
|
||||
向当前任务栏添加一个 16 x 16 像素的图标,通常用来覆盖一些应用的状态,或者直接来提示用户.
|
||||
|
||||
### `win.setHasShadow(hasShadow)` _OS X_
|
||||
|
||||
|
@ -690,7 +686,7 @@ sort of application status or to passively notify the user.
|
|||
|
||||
### `win.hasShadow()` _OS X_
|
||||
|
||||
返回设置窗口是否有阴影的状态.在Windows和Linux系统始终返回
|
||||
返回 boolean,设置窗口是否有阴影.在Windows和Linux系统始终返回
|
||||
`true`.
|
||||
|
||||
### `win.setThumbarButtons(buttons)` _Windows 7+_
|
||||
|
@ -732,7 +728,7 @@ sort of application status or to passively notify the user.
|
|||
|
||||
### `win.isMenuBarAutoHide()`
|
||||
|
||||
返回窗口的菜单栏是否可以自动隐藏的状态.
|
||||
返回 boolean,窗口的菜单栏是否可以自动隐藏.
|
||||
|
||||
### `win.setMenuBarVisibility(visible)`
|
||||
|
||||
|
@ -742,7 +738,7 @@ sort of application status or to passively notify the user.
|
|||
|
||||
### `win.isMenuBarVisible()`
|
||||
|
||||
返回菜单栏是否可见的状态.
|
||||
返回 boolean,菜单栏是否可见.
|
||||
|
||||
### `win.setVisibleOnAllWorkspaces(visible)`
|
||||
|
||||
|
@ -754,7 +750,7 @@ sort of application status or to passively notify the user.
|
|||
|
||||
### `win.isVisibleOnAllWorkspaces()`
|
||||
|
||||
返回窗口是否在所有地方都可见的状态.
|
||||
返回 boolean,窗口是否在所有地方都可见.
|
||||
|
||||
**注意:** 在 windows上始终返回 false.
|
||||
|
||||
|
|
129
docs-translations/zh-CN/api/content-tracing.md
Normal file
129
docs-translations/zh-CN/api/content-tracing.md
Normal file
|
@ -0,0 +1,129 @@
|
|||
# contentTracing
|
||||
|
||||
`content-tracing` 模块是用来收集由底层的Chromium content 模块 产生的搜索数据. 这个模块不具备web接口,所有需要我们在chrome浏览器中添加 `chrome://tracing/` 来加载生成文件从而查看结果.
|
||||
|
||||
```javascript
|
||||
const contentTracing = require('electron').contentTracing;
|
||||
|
||||
const options = {
|
||||
categoryFilter: '*',
|
||||
traceOptions: 'record-until-full,enable-sampling'
|
||||
}
|
||||
|
||||
contentTracing.startRecording(options, function() {
|
||||
console.log('Tracing started');
|
||||
|
||||
setTimeout(function() {
|
||||
contentTracing.stopRecording('', function(path) {
|
||||
console.log('Tracing data recorded to ' + path);
|
||||
});
|
||||
}, 5000);
|
||||
});
|
||||
```
|
||||
|
||||
## 方法
|
||||
|
||||
`content-tracing` 模块的方法如下:
|
||||
|
||||
### `contentTracing.getCategories(callback)`
|
||||
|
||||
* `callback` Function
|
||||
|
||||
获得一组分类组. 分类组可以更改为新的代码路径。
|
||||
|
||||
一旦所有的子进程都接受到了`getCategories`方法请求, 分类组将调用 `callback`.
|
||||
|
||||
### `contentTracing.startRecording(options, callback)`
|
||||
|
||||
* `options` Object
|
||||
* `categoryFilter` String
|
||||
* `traceOptions` String
|
||||
* `callback` Function
|
||||
|
||||
开始向所有进程进行记录.(recording)
|
||||
|
||||
一旦收到可以开始记录的请求,记录将会立马启动并且在子进程是异步记录听的. 当所有的子进程都收到 `startRecording` 请求的时候,`callback` 将会被调用.
|
||||
|
||||
`categoryFilter`是一个过滤器,它用来控制那些分类组应该被用来查找.过滤器应当有一个可选的 `-` 前缀来排除匹配的分类组.不允许同一个列表既是包含又是排斥.
|
||||
|
||||
例子:
|
||||
|
||||
* `test_MyTest*`,
|
||||
* `test_MyTest*,test_OtherStuff`,
|
||||
* `"-excluded_category1,-excluded_category2`
|
||||
|
||||
`traceOptions` 控制着哪种查找应该被启动,这是一个用逗号分隔的列表.可用参数如下:
|
||||
|
||||
* `record-until-full`
|
||||
* `record-continuously`
|
||||
* `trace-to-console`
|
||||
* `enable-sampling`
|
||||
* `enable-systrace`
|
||||
|
||||
前3个参数是来查找记录模块,并且以后都互斥.如果在`traceOptions` 中超过一个跟踪
|
||||
记录模式,那最后一个的优先级最高.如果没有指明跟踪
|
||||
记录模式,那么它默认为 `record-until-full`.
|
||||
|
||||
在 `traceOptions` 中的参数被解析应用之前,查找参数初始化默认为 (`record_mode` 设置为
|
||||
`record-until-full`, `enable_sampling` 和 `enable_systrace` 设置为 `false`).
|
||||
|
||||
### `contentTracing.stopRecording(resultFilePath, callback)`
|
||||
|
||||
* `resultFilePath` String
|
||||
* `callback` Function
|
||||
|
||||
停止对所有子进程的记录.
|
||||
|
||||
子进程通常缓存查找数据,并且仅仅将数据截取和发送给主进程.这有利于在通过 IPC 发送查找数据之前减小查找时的运行开销,这样做很有价值.因此,发送查找数据,我们应当异步通知所有子进程来截取任何待查找的数据.
|
||||
|
||||
一旦所有子进程接收到了 `stopRecording` 请求,将调用 `callback` ,并且返回一个包含查找数据的文件.
|
||||
|
||||
如果 `resultFilePath` 不为空,那么将把查找数据写入其中,否则写入一个临时文件.实际文件路径如果不为空,则将调用 `callback` .
|
||||
|
||||
### `contentTracing.startMonitoring(options, callback)`
|
||||
|
||||
* `options` Object
|
||||
* `categoryFilter` String
|
||||
* `traceOptions` String
|
||||
* `callback` Function
|
||||
|
||||
开始向所有进程进行监听.(monitoring)
|
||||
|
||||
一旦收到可以开始监听的请求,记录将会立马启动并且在子进程是异步记监听的. 当所有的子进程都收到 `startMonitoring` 请求的时候,`callback` 将会被调用.
|
||||
|
||||
### `contentTracing.stopMonitoring(callback)`
|
||||
|
||||
* `callback` Function
|
||||
|
||||
停止对所有子进程的监听.
|
||||
|
||||
一旦所有子进程接收到了 `stopMonitoring` 请求,将调用 `callback` .
|
||||
|
||||
### `contentTracing.captureMonitoringSnapshot(resultFilePath, callback)`
|
||||
|
||||
* `resultFilePath` String
|
||||
* `callback` Function
|
||||
|
||||
获取当前监听的查找数据.
|
||||
|
||||
子进程通常缓存查找数据,并且仅仅将数据截取和发送给主进程.因为如果直接通过 IPC 来发送查找数据的代价昂贵,我们宁愿避免不必要的查找运行开销.因此,为了停止查找,我们应当异步通知所有子进程来截取任何待查找的数据.
|
||||
|
||||
一旦所有子进程接收到了 `captureMonitoringSnapshot` 请求,将调用 `callback` ,并且返回一个包含查找数据的文件.
|
||||
|
||||
### `contentTracing.getTraceBufferUsage(callback)`
|
||||
|
||||
* `callback` Function
|
||||
|
||||
通过查找 buffer 进程来获取百分比最大使用量.当确定了TraceBufferUsage 的值确定的时候,就调用 `callback` .
|
||||
|
||||
### `contentTracing.setWatchEvent(categoryName, eventName, callback)`
|
||||
|
||||
* `categoryName` String
|
||||
* `eventName` String
|
||||
* `callback` Function
|
||||
|
||||
任意时刻在任何进程上指定事件发生时将调用 `callback` .
|
||||
|
||||
### `contentTracing.cancelWatchEvent()`
|
||||
|
||||
取消 watch 事件. 如果启动查找,这或许会造成 watch 事件的回调函数 出错.
|
Loading…
Add table
Reference in a new issue