|
@@ -153,10 +153,8 @@ const TaskLogWatcher = () => {
|
|
|
const { data } = await getTaskLog(params)
|
|
|
if (data.code === 200) {
|
|
|
setLogData(data.data.log)
|
|
|
- if (![2, 3].includes(data.data.status) && autoRefresh) {
|
|
|
- timeout = setTimeout(() => {
|
|
|
- fetchTaskLog(params)
|
|
|
- }, 5000)
|
|
|
+ if ([2, 3].includes(data.data.status)) {
|
|
|
+ clearInterval(timeout)
|
|
|
} else {
|
|
|
const index = jobList.findIndex(item => item.key === record.key)
|
|
|
const list = [...jobList]
|
|
@@ -176,11 +174,14 @@ const TaskLogWatcher = () => {
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (autoRefresh) {
|
|
|
- fetchTaskLog(selectJob)
|
|
|
+ clearInterval(timeout)
|
|
|
+ timeout = setInterval(() => {
|
|
|
+ fetchTaskLog(selectJob)
|
|
|
+ }, 5000)
|
|
|
} else {
|
|
|
- clearTimeout(timeout)
|
|
|
+ clearInterval(timeout)
|
|
|
}
|
|
|
- }, [autoRefresh])
|
|
|
+ }, [autoRefresh, selectJob])
|
|
|
|
|
|
const onClickRefresh = () => {
|
|
|
fetchTaskLog(selectJob)
|
|
@@ -202,7 +203,7 @@ const TaskLogWatcher = () => {
|
|
|
|
|
|
useEffect(() => {
|
|
|
return () => {
|
|
|
- clearTimeout(timeout)
|
|
|
+ clearInterval(timeout)
|
|
|
}
|
|
|
}, [])
|
|
|
|