电子应用程序 - 如何在不活动15分钟后自动注销用户?

时间:2016-08-15 18:45:05

标签: javascript timeout desktop-application logout electron

我正在制作一个电子应用程序,并想知道如何在不活动之后自动注销用户,比如15分钟!非常感谢!

const electron = require('electron');
const app = electron.app;

let willQuitApp = false;
let window;

app.on('ready', () => {
  window = new electron.BrowserWindow();

  window.on('close', (e) => {
    if (willQuitApp) {
    window = null;
   } else {
      /* the user only tried to close the window */
    e.preventDefault();
    window.hide();
   }
  });

  window.loadURL(`mypage`); /* load your page */

});
app.on('activate', () => window.show());

app.on('before-quit', () => willQuitApp = true);

1 个答案:

答案 0 :(得分:1)

Electron Power monitor API's,然后 实现一个Interval函数来检查时间是否超过15分钟,然后注销用户

  id      dates  later
0  A 2000-01-01      1
1  B 2000-01-02      0
2  C 2000-01-03      1