init
This commit is contained in:
45
src/components/Back.vue
Normal file
45
src/components/Back.vue
Normal file
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<div></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Back',
|
||||
data () {
|
||||
return {
|
||||
lockTime: this.$store.getters.lockTime,
|
||||
timeOut: null,
|
||||
actions: ['mouseup', 'mousemove', 'keyup', 'click', 'touchend']
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
if (Number(this.lockTime) !== 0) {
|
||||
this.isTimeOut()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
startTimer () {
|
||||
// console.log('8')
|
||||
clearInterval(this.timeOut)
|
||||
this.timeOut = setInterval(() => {
|
||||
this.$router.push({path: '/'})
|
||||
// console.log('time', 1000 * 6 * this.lockTime)
|
||||
}, 1000 * 60 * this.lockTime)
|
||||
},
|
||||
isTimeOut () {
|
||||
this.startTimer()
|
||||
this.actions.forEach(item => {
|
||||
document.body.addEventListener(item, this.startTimer)
|
||||
})
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
this.actions.forEach(item => {
|
||||
// console.log(item)
|
||||
document.body.removeEventListener(item, this.startTimer)
|
||||
})
|
||||
clearInterval(this.timeOut)
|
||||
this.timeOut = null
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user