natasha 2 tahun lalu
induk
melakukan
376c234b66
1 mengubah file dengan 42 tambahan dan 0 penghapusan
  1. 42 0
      src/App.vue

+ 42 - 0
src/App.vue

@@ -18,12 +18,17 @@
   </div>
 </template>
 <script>
+import { removeSession } from "@/utils/role";
+import { removeToken } from "@/utils/auth";
+import Cookies from "js-cookie";
+import data from './common/data';
 export default {
   name: "App",
   data() {
     return {
       dir: "ltr",
       userAgentTipShow: false,
+      timeOut: null
     };
   },
   created() {
@@ -40,6 +45,21 @@ export default {
     } else {
       this.handleUserAgentRoot();
     }
+    window.addEventListener(
+        'click',()=>{
+            sessionStorage.setItem('lastClickTime',new Date().getTime())
+        }
+    )
+    window.addEventListener(
+        'mousewheel',()=>{
+            sessionStorage.setItem('lastClickTime',new Date().getTime())
+        }
+    )
+    window.addEventListener(
+        'mousemove',()=>{
+            sessionStorage.setItem('lastClickTime',new Date().getTime())
+        }
+    )
   },
   methods: {
     // 判断是否为chrome浏览器
@@ -55,6 +75,28 @@ export default {
       sessionStorage.setItem("useragent_root_close", true);
       this.userAgentTipShow = false;
     },
+    // 是否超时
+    isTimeOut(){
+        clearInterval(this.timeOut)
+        this.timeOut = setInterval(()=>{
+            let lastClickTime = sessionStorage.getItem('lastClickTime')*1
+            let nowTime = new Date().getTime()
+            if(nowTime - lastClickTime > 1000 * 5){
+                clearInterval(this.timeOut)
+                removeSession("SysList");
+                removeToken();
+                Cookies.remove("JSESSIONID");
+                this.userShow = false;
+                this.userMessage = null;
+                sessionStorage.removeItem("useragent_root_close");
+                window.location.href = 'https://gcls.helxsoft.cn/'
+            }
+        })
+    }
+  },
+  mounted(){
+    sessionStorage.setItem('lastClickTime',new Date().getTime())
+    this.isTimeOut()
   },
 };
 </script>