powerSaveBlocker to zh-CN
This commit is contained in:
parent
50fbd5266a
commit
6a0738aa88
1 changed files with 24 additions and 20 deletions
|
@ -1,13 +1,15 @@
|
||||||
# powerSaveBlocker
|
# powerSaveBlocker
|
||||||
|
|
||||||
`powerSaveBlocker` 模块是用来阻止应用系统进入睡眠模式的,因此这允许应用保持系统和屏幕继续工作.
|
> 阻止系统进入低功耗(睡眠)模式。
|
||||||
|
|
||||||
|
进程: [Main](../glossary.md#main-process)
|
||||||
|
|
||||||
例如:
|
例如:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const powerSaveBlocker = require('electron').powerSaveBlocker
|
const {powerSaveBlocker} = require('electron')
|
||||||
|
|
||||||
var id = powerSaveBlocker.start('prevent-display-sleep')
|
const id = powerSaveBlocker.start('prevent-display-sleep')
|
||||||
console.log(powerSaveBlocker.isStarted(id))
|
console.log(powerSaveBlocker.isStarted(id))
|
||||||
|
|
||||||
powerSaveBlocker.stop(id)
|
powerSaveBlocker.stop(id)
|
||||||
|
@ -15,34 +17,36 @@ powerSaveBlocker.stop(id)
|
||||||
|
|
||||||
## 方法
|
## 方法
|
||||||
|
|
||||||
`powerSaveBlocker` 模块有如下方法:
|
`powerSaveBlocker` 模块有如下方法:
|
||||||
|
|
||||||
### `powerSaveBlocker.start(type)`
|
### `powerSaveBlocker.start(type)`
|
||||||
|
|
||||||
* `type` String - 强行保存阻塞类型.
|
* `type` String - 强行保存阻塞类型。
|
||||||
* `prevent-app-suspension` - 阻止应用挂起.
|
* `prevent-app-suspension` - 阻止应用挂起。
|
||||||
保持系统活跃,但是允许屏幕不亮. 用例:
|
保持系统活跃,但是允许屏幕不亮。例如:
|
||||||
下载文件或者播放音频.
|
下载文件或者播放音频。
|
||||||
* `prevent-display-sleep`- 阻止应用进入休眠. 保持系统和屏幕活跃,屏幕一直亮. 用例: 播放音频.
|
* `prevent-display-sleep`- 阻止应用进入休眠。保持系统和屏幕活跃,屏幕一直亮。例如:播放音频。
|
||||||
|
|
||||||
开始阻止系统进入睡眠模式.返回一个整数,这个整数标识了保持活跃的blocker.
|
返回 `Integer` - 分配给此阻断器的 blocker ID
|
||||||
|
|
||||||
**注意:** `prevent-display-sleep` 有更高的优先级
|
开始阻止系统进入睡眠模式。返回一个整数,这个整数标识了保持活跃的blocker ID。
|
||||||
`prevent-app-suspension`. 只有最高优先级生效. 换句话说, `prevent-display-sleep` 优先级永远高于
|
|
||||||
`prevent-app-suspension`.
|
|
||||||
|
|
||||||
例如, A 请求调用了 `prevent-app-suspension`, B请求调用了 `prevent-display-sleep`. `prevent-display-sleep`
|
**注意:** `prevent-display-sleep` 有更高的优先级
|
||||||
将一直工作,直到B停止调用. 在那之后, `prevent-app-suspension`
|
`prevent-app-suspension`。只有最高优先级生效,换句话说, `prevent-display-sleep` 优先级永远高于
|
||||||
才起效.
|
`prevent-app-suspension`。
|
||||||
|
|
||||||
|
例如, A 请求调用了 `prevent-app-suspension`,B请求调用了 `prevent-display-sleep`。`prevent-display-sleep`
|
||||||
|
将一直工作,直到B停止调用。在那之后,`prevent-app-suspension`
|
||||||
|
才起效。
|
||||||
|
|
||||||
### `powerSaveBlocker.stop(id)`
|
### `powerSaveBlocker.stop(id)`
|
||||||
|
|
||||||
* `id` Integer - 通过 `powerSaveBlocker.start` 返回的保持活跃的 blocker id.
|
* `id` Integer - 通过 `powerSaveBlocker.start` 返回保持活跃的 blocker id.
|
||||||
|
|
||||||
让指定blocker 停止活跃.
|
让指定 blocker 停止活跃。
|
||||||
|
|
||||||
### `powerSaveBlocker.isStarted(id)`
|
### `powerSaveBlocker.isStarted(id)`
|
||||||
|
|
||||||
* `id` Integer - 通过 `powerSaveBlocker.start` 返回的保持活跃的 blocker id.
|
* `id` Integer - 通过 `powerSaveBlocker.start` 返回保持活跃的 blocker id.
|
||||||
|
|
||||||
返回 boolean, 是否对应的 `powerSaveBlocker` 已经启动.
|
返回 boolean,对应的 `powerSaveBlocker` 是否已经启动。
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue