1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| (function () { const LOGOUT_TIME_LEN = 1000 * 60 * 10;
let time = new Date().getTime();
window.onmouseup = function countTime() { time = new Date().getTime(); };
const id = window.setInterval(function () { if (new Date().getTime() - time > LOGOUT_TIME_LEN) { storage.clear(); window.clearInterval(id); alert("由于您长时间没有操作, session已过期, 请重新登录"); window.open('/views/login/login.html', '_self'); } }, 1000 * 60); })();
|