mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-05-12 02:21:06 +08:00
Merge pull request #348 from Aqr-K/fix-progress
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 停止监听加载进度
|
||||
|
||||
Reference in New Issue
Block a user