From 3bade2060a226c4fcc79f7bfc16bb22829ddf153 Mon Sep 17 00:00:00 2001 From: Aqr-K <95741669+Aqr-K@users.noreply.github.com> Date: Thu, 26 Jun 2025 14:31:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(progress):=20=E4=BF=AE=E5=A4=8D=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E7=82=B9=E5=87=BB=E6=97=B6=EF=BC=8C`progressEventSour?= =?UTF-8?q?ce`=20=E8=A2=AB=E8=A6=86=E7=9B=96=E4=BC=9A=E4=BA=A7=E7=94=9F?= =?UTF-8?q?=E5=AD=A4=E5=84=BF=E4=BA=8B=E4=BB=B6=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/dialog/ReorganizeDialog.vue | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/components/dialog/ReorganizeDialog.vue b/src/components/dialog/ReorganizeDialog.vue index b0e75b35..2da58d44 100644 --- a/src/components/dialog/ReorganizeDialog.vue +++ b/src/components/dialog/ReorganizeDialog.vue @@ -188,6 +188,11 @@ async function handleTransferLog(logid: number, background: boolean = false) { // 使用SSE监听加载进度 function startLoadingProgress() { + // 在创建新连接之前,先确保任何可能存在的旧连接都被关闭了,防止因快速重复点击而产生孤儿连接。 + if (progressEventSource.value) { + progressEventSource.value.close() + } + progressText.value = t('dialog.reorganize.processing') progressEventSource.value = new EventSource(`${import.meta.env.VITE_API_BASE_URL}system/progress/filetransfer`) progressEventSource.value.onmessage = event => { @@ -197,6 +202,13 @@ function startLoadingProgress() { progressValue.value = progress.value } } + + // 发生错误时,也确保连接被关闭,避免重试等意外行为 + progressEventSource.value.onerror = () => { + if (progressEventSource.value) { + progressEventSource.value.close() + } + } } // 停止监听加载进度