Leo 2 years ago
parent
commit
6af1d5fa53
1 changed files with 8 additions and 5 deletions
  1. 8 5
      src/module/datasource/component/LogWatcher.jsx

+ 8 - 5
src/module/datasource/component/LogWatcher.jsx

@@ -56,6 +56,14 @@ const LogWatcher = () => {
     fetchOnceJoblog()
   }, [state])
 
+  useEffect(() => {
+    if (autoRefresh) {
+      fetchOnceJoblog()
+    } else {
+      clearTimeout(timeout)
+    }
+  }, [autoRefresh])
+
   const returnLogTable = () => {
     navigate('/datasource', {
       state: {
@@ -68,11 +76,6 @@ const LogWatcher = () => {
   }
 
   const changeRefresh = e => {
-    if (e.target.checked) {
-      fetchOnceJoblog()
-    } else {
-      clearTimeout(timeout)
-    }
     setAutoRefresh(e.target.checked)
   }