Browse Source

feat 三十分钟无操作跳出

anxiaoxia 2 năm trước cách đây
mục cha
commit
229c06494b
1 tập tin đã thay đổi với 22 bổ sung2 xóa
  1. 22 2
      src/layouts/index.jsx

+ 22 - 2
src/layouts/index.jsx

@@ -1,4 +1,4 @@
-import React, { useState, useEffect } from 'react';
+import React, { useState, useEffect, useRef } from 'react';
 import { useModel, useLocation, useIntl } from 'umi';
 import styles from './index.less';
 import { MenuFoldOutlined, SmileOutlined } from '@ant-design/icons';
@@ -104,8 +104,28 @@ export default (props) => {
     //debugger;
     console.log('location', location);
   }, [location]);
+
+  let setTimer = useRef();
+  clearTimeout(setTimer.current);
+  setTimer.current = null;
+  setTimer.current = setTimeout(() => {
+    window.open('http://10.100.28.70', '_self');
+  }, 1000 * 60 * 30);
+  useEffect(() => {
+    clearTimeout(setTimer.current);
+    setTimer.current = null;
+  }, []);
   return (
-    <div className={styles.layout}>
+    <div
+      className={styles.layout}
+      onClick={(event) => {
+        clearTimeout(setTimer.current);
+        setTimer.current = null;
+        setTimer.current = setTimeout(() => {
+          window.open('http://10.100.28.70', '_self');
+        }, 1000 * 60 * 30);
+      }}
+    >
       <div className={styles.header}>
         <div className={styles.title}>之江项目</div>
         <div className={styles.right}>