powerMonitor
进程:主进程
powerMonitor
模块触发以下事件:
在系统挂起时触发。
Event: ‘resume’
在系统恢复时触发。
Event: ‘on-ac’ macOS Windows
当系统变为交流电源时触发。
Event: ‘on-battery’ macOS Windows
当系统更改为电池电量时触发。
Event: ‘lock-screen’ macOS Windows
当系统即将锁定屏幕时触发。
Event: ‘unlock-screen’ macOS Windows
当系统屏幕解锁,立即触发。
事件: ‘user-did-groupe-active’ macOS
当应用被激活时发出。 更多信息请访问 。
当应用被激活时发出。 更多信息请访问 文档。
模块具有以下方法:
powerMonitor.getSystemIdleState(idleThreshold)
idleThreshold
Integer
Returns String
- 系统当前状态。 可以被设置为active
,idle
,locked
或者unknown
powerMonitor.getSystemIdleTime()
Returns Integer
- 几秒钟内的空闲时间
计算系统空闲时间以秒为单位。
powerMonitor.isOnBatteryPower()
返回Boolean
,表示系统是否使用电池电源。
要监视此属性的变化,请使用 on-battery
和 on-ac<
事件。
Boolean
属性。 如果系统处于电池电源状态,则为 true。