<template>
  <div id="app" @mousemove="moveEvent" @click="moveEvent">
    <!--<keep-alive>
    <router-view v-if="$route.meta.keepAlive"></router-view>
    </keep-alive>
    <router-view v-if="!$route.meta.keepAlive"></router-view>-->

    <router-view ></router-view>
  </div>
</template>



<script>
  
export default {
  name: 'App',
  /**
   * 监听浏览器刷新
   */
  data(){
    return {
      timmer: null,
     
    }
  },
  
  methods: {
    moveEvent(){
//				console.log("清除了定时器!!!!!")
      let path = ['/login']
      if(!path.includes(this.$route.path)) { //如果不是登录页面的话页面停止进行30分钟后清空session
        clearTimeout(this.timmer);
        this.init();
      }

    },

    init(){
      this.timmer=setTimeout(()=>{
    
        //清除session
        sessionStorage.removeItem("sessionData");
        sessionStorage.clear();
        //清除缓存
        this.$cache.reset();
        //跳往登录页面
        this.$router.push({
          path: "/login",

      });

      },30*60*1000);//设置半小时清空session进入屏保
    },


  }
}
</script>

 

Logo

前往低代码交流专区

更多推荐