Electron powerMonitor 模塊

2019-08-14 19:21 更新

power-monitor模塊是用來監(jiān)聽能源區(qū)改變的.只能在主進(jìn)程中使用.在 app 模塊的 ready 事件觸發(fā)之后就不能使用這個(gè)模塊了.

例如:

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

事件

power-monitor 模塊可以觸發(fā)下列事件:

Event: 'suspend'

在系統(tǒng)掛起的時(shí)候觸發(fā).

Event: 'resume'

在系統(tǒng)恢復(fù)繼續(xù)工作的時(shí)候觸發(fā). Emitted when system is resuming.

Event: 'on-ac'

在系統(tǒng)使用交流電的時(shí)候觸發(fā). Emitted when the system changes to AC power.

Event: 'on-battery'

在系統(tǒng)使用電池電源的時(shí)候觸發(fā). Emitted when system changes to battery power.

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號