Electron powerMonitor 模块

power-monitor模块是用来监听能源区改变的.只能在主进程中使用.在 app 模块的 ready 事件触发之后就不能使用这个模块了.

例如:

app.on('ready', function() {
  require('electron').powerMonitor.on('suspend', function() {
      console.log('The system is going to sleep');
  });
});

事件

power-monitor 模块可以触发下列事件:

Event: 'suspend'

在系统挂起的时候触发.

Event: 'resume'

在系统恢复继续工作的时候触发. Emitted when system is resuming.

Event: 'on-ac'

在系统使用交流电的时候触发. Emitted when the system changes to AC power.

Event: 'on-battery'

在系统使用电池电源的时候触发. Emitted when system changes to battery power.

相关文章

这篇文章主要讲解了“electron打包中的坑如何解决”,文中的...
这篇文章主要介绍“electron打包的坑如何解决”的相关知识,...
这篇文章主要为大家分析了VSCode中如何调试Electron应用的主...
这篇“如何在VSCode上调试Electron应用的主进程代码”文章的...
vue-cli+electron一种新的脚手架(vue-electron)vue-electron...
1、首先成功安装Node.js。2、配置好环境变量path,参加上一篇...