fix:光芯大屏定时刷新页面
This commit is contained in:
parent
4984c6a9a4
commit
235e221606
|
@ -506,6 +506,7 @@ export default {
|
||||||
configData5:{},
|
configData5:{},
|
||||||
scrollNum:0,
|
scrollNum:0,
|
||||||
scrollInterval:null,
|
scrollInterval:null,
|
||||||
|
reloadInterval:null,
|
||||||
//近七天日数组
|
//近七天日数组
|
||||||
dayArr:[],
|
dayArr:[],
|
||||||
visibals0: false,
|
visibals0: false,
|
||||||
|
@ -525,6 +526,7 @@ export default {
|
||||||
lineWidth:0,
|
lineWidth:0,
|
||||||
pieHeight:0,
|
pieHeight:0,
|
||||||
lineHeight:0,
|
lineHeight:0,
|
||||||
|
timeoutDuration : 86400000,
|
||||||
setIntervals:null,
|
setIntervals:null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -544,6 +546,38 @@ export default {
|
||||||
this.timerTime = setInterval(() => {
|
this.timerTime = setInterval(() => {
|
||||||
this.showTime();
|
this.showTime();
|
||||||
}, 1000);
|
}, 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: {
|
methods: {
|
||||||
//初始化视图
|
//初始化视图
|
||||||
|
@ -1026,9 +1060,11 @@ export default {
|
||||||
clearInterval(that.timerTime);
|
clearInterval(that.timerTime);
|
||||||
clearInterval(that.scrollInterval);
|
clearInterval(that.scrollInterval);
|
||||||
clearInterval(that.setIntervals);
|
clearInterval(that.setIntervals);
|
||||||
|
clearInterval(that.reloadInterval);
|
||||||
that.timerTime = null;
|
that.timerTime = null;
|
||||||
that.scrollInterval = null;
|
that.scrollInterval = null;
|
||||||
that.setIntervals = null;
|
that.setIntervals = null;
|
||||||
|
that.reloadInterval = null;
|
||||||
},
|
},
|
||||||
beforeDestoryed() {
|
beforeDestoryed() {
|
||||||
let that = this;
|
let that = this;
|
||||||
|
@ -1036,9 +1072,11 @@ export default {
|
||||||
clearInterval(that.timerTime);
|
clearInterval(that.timerTime);
|
||||||
clearInterval(that.scrollInterval);
|
clearInterval(that.scrollInterval);
|
||||||
clearInterval(that.setIntervals);
|
clearInterval(that.setIntervals);
|
||||||
|
clearInterval(that.reloadInterval);
|
||||||
that.timerTime = null;
|
that.timerTime = null;
|
||||||
that.scrollInterval = null;
|
that.scrollInterval = null;
|
||||||
that.setIntervals = null;
|
that.setIntervals = null;
|
||||||
|
that.reloadInterval = null;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue