Explorar o código

fix 延时跳转

anxiaoxia %!s(int64=2) %!d(string=hai) anos
pai
achega
378a1b8010
Modificáronse 1 ficheiros con 15 adicións e 6 borrados
  1. 15 6
      src/layouts/index.jsx

+ 15 - 6
src/layouts/index.jsx

@@ -108,15 +108,21 @@ export default (props) => {
   let setTimer = useRef();
   clearTimeout(setTimer.current);
   setTimer.current = null;
+  let timerTwo = useRef();
   setTimer.current = setTimeout(() => {
     console.log('----没有点击,退出');
-    window.parent.sessionStorage.clear();
+    clearTimeout(timerTwo.current);
+    timerTwo.current = null;
     window.parent.localStorage.clear();
-    window.open('http://10.100.28.70/saasweb/login', '_top');
-  }, 1000 * 60 * 30);
+    timerTwo.current = setTimeout(() => {
+      window.open('http://10.100.28.70/saasweb/login', '_top');
+    }, 1000);
+  }, 1000 * 60 * 5);
   useEffect(() => {
     clearTimeout(setTimer.current);
     setTimer.current = null;
+    clearTimeout(timerTwo.current);
+    timerTwo.current = null;
   }, []);
   return (
     <div
@@ -126,10 +132,13 @@ export default (props) => {
         setTimer.current = null;
         setTimer.current = setTimeout(() => {
           console.log('----点击,退出');
-          window.parent.sessionStorage.clear();
+          clearTimeout(timerTwo.current);
+          timerTwo.current = null;
           window.parent.localStorage.clear();
-          window.open('http://10.100.28.70/saasweb/login', '_top');
-        }, 1000 * 60 * 30);
+          timerTwo.current = setTimeout(() => {
+            window.open('http://10.100.28.70/saasweb/login', '_top');
+          }, 1000);
+        }, 1000 * 60 * 5);
       }}
     >
       <div className={styles.header}>