由于系统的安全性考虑,系统添加长时间操作自动跳出,跳到登录页面
首先在util文件夹下面创建一个js
import store from '@/store'
export default function () {
let lastTime = new Date().getTime();
let currentTime = new Date().getTime();
let timeOut = 30 * 60 * 1000;
window.onload = function () {
window.document.onmousedown = function () {
localStorage.setItem("lastTime", new Date().getTime())
}
};
function checkTimeout() {
currentTime = new Date().getTime();
lastTime = localStorage.getItem("lastTime");
if (currentTime - lastTime > timeOut) {
store.dispatch('LogOut').then(() => {
location.href = '/htyy/index';
})
}
}
/* 定时器 间隔30秒检测是否长时间未操作页面 */
window.setInterval(checkTimeout, 30000);
}
通过timeOut自定义几分钟跳出登录页面。
然后再main.js里面引入