Merge branch 'master' of http://gitea.xxhhcty.xyz:8080/zcdsj/factory_web
This commit is contained in:
commit
422bb84990
|
@ -506,6 +506,7 @@ export default {
|
|||
configData5:{},
|
||||
scrollNum:0,
|
||||
scrollInterval:null,
|
||||
reloadInterval:null,
|
||||
//近七天日数组
|
||||
dayArr:[],
|
||||
visibals0: false,
|
||||
|
@ -525,6 +526,7 @@ export default {
|
|||
lineWidth:0,
|
||||
pieHeight:0,
|
||||
lineHeight:0,
|
||||
timeoutDuration : 86400000,
|
||||
setIntervals:null,
|
||||
};
|
||||
},
|
||||
|
@ -544,6 +546,38 @@ export default {
|
|||
this.timerTime = setInterval(() => {
|
||||
this.showTime();
|
||||
}, 1000);
|
||||
|
||||
|
||||
let lastActiveTime = new Date().getTime();
|
||||
let timer;
|
||||
// 重置最后活动时间并重启计时器
|
||||
function resetActiveTime() {
|
||||
console.log('用户活动');
|
||||
lastActiveTime = new Date().getTime();
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(checkIdleTime, that.timeoutDuration);
|
||||
}
|
||||
// 检查是否超时
|
||||
function checkIdleTime() {
|
||||
let currentTime = new Date().getTime();
|
||||
if (currentTime - lastActiveTime > that.timeoutDuration) {
|
||||
refreshPage();
|
||||
} else {
|
||||
resetActiveTime();
|
||||
}
|
||||
}
|
||||
// 刷新页面函数
|
||||
function refreshPage() {
|
||||
window.location.reload(true);
|
||||
}
|
||||
// 监听所有可能触发用户活动的行为并重置最后活动时间
|
||||
document.addEventListener('click', resetActiveTime);
|
||||
document.addEventListener('keypress', resetActiveTime);
|
||||
document.addEventListener('scroll', resetActiveTime);
|
||||
document.addEventListener('mousemove', resetActiveTime);
|
||||
that.reloadInterval = setInterval(() => {
|
||||
window.location.reload(true);
|
||||
},86400000)
|
||||
},
|
||||
methods: {
|
||||
//初始化视图
|
||||
|
@ -1026,9 +1060,11 @@ export default {
|
|||
clearInterval(that.timerTime);
|
||||
clearInterval(that.scrollInterval);
|
||||
clearInterval(that.setIntervals);
|
||||
clearInterval(that.reloadInterval);
|
||||
that.timerTime = null;
|
||||
that.scrollInterval = null;
|
||||
that.setIntervals = null;
|
||||
that.reloadInterval = null;
|
||||
},
|
||||
beforeDestoryed() {
|
||||
let that = this;
|
||||
|
@ -1036,9 +1072,11 @@ export default {
|
|||
clearInterval(that.timerTime);
|
||||
clearInterval(that.scrollInterval);
|
||||
clearInterval(that.setIntervals);
|
||||
clearInterval(that.reloadInterval);
|
||||
that.timerTime = null;
|
||||
that.scrollInterval = null;
|
||||
that.setIntervals = null;
|
||||
that.reloadInterval = null;
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue