From c10fc513cb555612bd92f43391422f1f0f80a315 Mon Sep 17 00:00:00 2001 From: xlsea Date: Sat, 13 Jul 2024 11:30:39 +0800 Subject: [PATCH] =?UTF-8?q?feat(sj=5F1.1.0-beta3):=20=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=96=B0=E5=A2=9E=E7=8A=B6=E6=80=81=E7=9B=91?= =?UTF-8?q?=E6=B5=8B=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/log-drawer.vue | 33 +++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/components/common/log-drawer.vue b/src/components/common/log-drawer.vue index f6af1db..4a0652a 100644 --- a/src/components/common/log-drawer.vue +++ b/src/components/common/log-drawer.vue @@ -67,6 +67,7 @@ const stopLog = () => { }; async function getLogList() { + clearTimeout(interval.value); let logData = null; let logError; @@ -114,14 +115,44 @@ async function getLogList() { if (isAutoScroll.value) virtualListInst.value?.scrollTo({ position: 'bottom', debounce: true }); }); if (!finished.value && syncTime.value !== 0) { - clearTimeout(interval.value); interval.value = setTimeout(getLogList, syncTime.value * 1000); } + + if (finished.value && syncTime.value !== 0) { + setTimeout(() => { + watchFinished(); + }, 5 * 1000); + } } else if (logError?.code !== 'ERR_CANCELED') { stopLog(); } } +async function watchFinished() { + clearTimeout(interval.value); + if (props.type === 'job' && syncTime.value !== 0) { + const taskData = props.taskData! as Api.Job.JobTask; + const { data, error } = await fetchJobLogList( + { + taskBatchId: taskData.taskBatchId, + jobId: taskData.jobId, + taskId: taskData.id, + startId, + fromIndex, + size: 50 + }, + controller + ); + if (!error && data) { + if (data.finished) { + interval.value = setTimeout(watchFinished, 5 * 1000); + return; + } + await getLogList(); + } + } +} + onBeforeUnmount(() => { stopLog(); });