admin管理员组文章数量:1429931
I am making an electron app and wonder how I can automatically log out the user after being inactive for lets say 15 minutes! Thanks a lot!
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);
I am making an electron app and wonder how I can automatically log out the user after being inactive for lets say 15 minutes! Thanks a lot!
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);
Share
Improve this question
asked Aug 15, 2016 at 18:45
javascript2016javascript2016
1,0134 gold badges20 silver badges41 bronze badges
2 Answers
Reset to default 4If you're interested in idle time in your app specifically then this has been previously answered. On the other hand if you're interested in system idle time then you'll want to use https://github./paulcbetts/node-system-idle-time
Look at Electron Power monitor API's and implement an Interval function to check if time is more than 15 minutes then log out user
const {powerMonitor} = require('electron');
const idle = powerMonitor.getSystemIdleTime() // it returns in seconds when I am writing this
console.log('Current System Idle Time - ', idle);
版权声明:本文标题:javascript - Electron App -How to automatically log out a user after inactivity for 15 minutes? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745496762a2660840.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论