whychdw
2022-01-04 02b0b12ef747d5d5d794ccbf0f51c11e28911a53
内容提交
2个文件已修改
50 ■■■■■ 已修改文件
src/components/PageHeader.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/home.vue 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/PageHeader.vue
@@ -1135,7 +1135,7 @@
        // 设置pageConfig
        this.$store.dispatch('user/changeRealTabsConfig', []);
      })
    }
    },
  },
  computed: {
    processAlarmMsg() {
src/pages/home.vue
@@ -1,11 +1,12 @@
<template>
  <flex-layout class="page-home" no-bg>
  <flex-layout class="page-home" no-bg ref="homeRoot">
    <page-header
      slot="header"
      :class="{ 'show-drawer': drawer }"
      @handle-message="handleMessage"
    ></page-header>
    <div class="page-home-content" :class="{ 'show-drawer': drawer }">
    <div ref="homeContent" class="page-home-content" :class="{ 'show-drawer': drawer }">
      <div class="home-content-mask" v-if="showMash"></div>
      <div class="tab-menu-left" @click="drawer = true">
        <i class="el-icon-s-operation"></i>
      </div>
@@ -60,6 +61,7 @@
import marqueeLeft from "@/components/marqueeLeft";
import getPageMenu from "@/assets/js/tools/getPageMenu";
import { checkUserLogin, getAllRealAlarm } from "@/assets/js/api";
import {Timeout} from "@/assets/js/tools";
let timer;
export default {
@@ -95,10 +97,13 @@
      tabs: tabs,
      drawer: false,
      timer: "",
      timer2: new Timeout(),
      hdwDialog: false,
      areas: [],
      socket: "",
      path: "ws://localhost:8919/fg/websocket/loginCheck",
      lastTime: new Date().getTime(),
      showMash: false,
    };
  },
  watch: {
@@ -234,6 +239,27 @@
          }, 5000);
        });
    },
    changeLastTime() {
      this.lastTime = new Date().getTime()
    },
    listenLastTime() {
      this.timer2.start(()=>{
        let lastTime = this.lastTime;
        let currentTime = new Date().getTime(); //更新当前时间
        let timeOut = 30 * 60 * 1000; //设置超时时间: 30分
        if(currentTime - lastTime > timeOut){ //判断是否超时
          alert("长时间未操作,自动退出!");
          this.$router.push("/login");
        }else if(currentTime - lastTime > timeOut/2) {
          this.showMash = true;
          this.timer2.open();
        }else{
          this.showMash = false;
          this.timer2.open();
        }
      }, 1000);
    }
  },
  computed: {
    showMarqueeLeft() {
@@ -254,8 +280,18 @@
    setInterval(() => {
      this.getAllRealAlarm();
    }, 1000);
    // 开启监控鼠标移动
    window.addEventListener("mousemove", this.changeLastTime);
    // 启动监控
    this.listenLastTime();
  },
  destroyed() {},
  destroyed() {
    // 移除监控鼠标移动
    window.removeEventListener("mousemove", this.changeLastTime);
    this.timer2.stop();
  },
};
</script>
@@ -299,4 +335,10 @@
  line-height: 40px;
  text-align: center;
}
.home-content-mask {
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 9999;
}
</style>