<template>
  <div id="app"   @mousemove="handleTime">
    <router-view/>
  </div>
</template>

<script>

export default {
  name: 'App',
  components: {
  },
  created() {
    this.$global.lastTime = new Date().getTime(); //网页第一次打开时，记录当前时间
    clearInterval(this.$global.freeTimer);
    this.JudgeFreeTimer();
    //this.setOperationTime();
  },
  methods: {
    JudgeFreeTimer(){
      this.$global.freeTimer = setInterval(() => {
        this.$global.currentTime = new Date().getTime();
        //console.log(this.$global)
        if (this.$global.currentTime - this.$global.lastTime > this.$global.timeOut) {
          //判断上次最后一次点击的时间和这次点击的时间间隔是否大于15分钟
          //大于15分钟,跳转路由到login页
          //this.$store.dispatch("user/logout");
          localStorage.setItem("zhfx_usercode", "");
          localStorage.setItem("zhfx_username", "");
          localStorage.setItem("zhfx_unitcode", "");
          localStorage.setItem("zhfx_unitname", "");
          localStorage.setItem("zhfx_lasttime", "");
          localStorage.setItem("zhfx_role", "");
          localStorage.setItem("zhfx_userkeycode", "");
          localStorage.setItem("zhfx_changetime", "");
          localStorage.setItem("zhfx_role_uuid", "");
          this.$router.push("/login");
        }
      }, 1000);
    },

    handleTime() {
      this.$global.lastTime = new Date().getTime(); //记录这次点击的时间
      if(localStorage.getItem("zhfx_userkeycode")==""){
        this.$router.push("/login");
      }
    },
  },
}
</script>

<style>
html,body,#app {
  height: 100%;
  width: 100%;
  overflow: hidden;
  margin: 0px 0px 0px 0px;
}
</style>
