<template> <div id="app" @mousemove="moveEvent" @click="moveEvent"> <router-view /> </div> </template> <script> export default { name: 'App', data() { return { timmer: null } }, methods: { moveEvent: function() { const path = ['/login'] if (!path.includes(this.$route.path)) { clearTimeout(this.timmer) this.init() } }, init: function() { this.timmer = setTimeout(() => { sessionStorage.clear() this.logout() }, 1000 * 60 * 151) // 15分钟 https://blog.csdn.net/qq_42345108/article/details/103496456 }, logout() { this.$store.dispatch('LogOut').then(() => { location.reload() }) } } } </script>