> For the complete documentation index, see [llms.txt](https://yuzhigang5460.gitbook.io/electron/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yuzhigang5460.gitbook.io/electron/api/api-jie-kou-zhi-zhu-jin-cheng-jie-kou/power-monitor.md).

# 电源状态

> 监视电源状态

进程: [主进程](https://yuzhigang5460.gitbook.io/electron/api/api-jie-kou-zhi-zhu-jin-cheng-jie-kou/pages/-MAVO-KXutpOPnOtQtKR#主进程)

该模块在主进程 `app` 模块的 `ready` 事件前使用.

```javascript
const electron = require('electron')
const {app} = electron

app.on('ready', () => {
  electron.powerMonitor.on('suspend', () => {
    console.log('系统即将进入睡眠')
  })
})
```

## 事件列表

### 事件:'suspend'

> 触发:**系统挂起时**

### 事件:`resume`

> 触发:**系统恢复时**

### 事件:'on-ac'*Windows*

> 触发:**系统更改为交流电源时**

### 事件:'on-battery'*Windows*

> 触发:**系统更改为电池电源时**
