From a598fac255e2b0edb056621224fe3927e0476031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E9=93=B6=E5=86=9B?= Date: Mon, 21 Sep 2026 23:21:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(pkglist):=20=E6=8B=89=E5=8F=96=E7=9E=AC?= =?UTF-8?q?=E9=97=B4=E5=AE=8C=E6=88=90=E6=97=B6=E4=B8=8D=E5=86=8D=E8=AF=AF?= =?UTF-8?q?=E5=BC=B9=E3=80=8C=E6=AD=A3=E5=9C=A8=E9=87=8D=E6=96=B0=E6=8B=89?= =?UTF-8?q?=E5=8F=96=E3=80=8D=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 同一轮询同时带回 round≥2 与 running=false 时,轮次 watcher 误判为开始重试, 导致「正在重新拉取」与「拉取完成」两条提示同屏出现;增加 running 守卫, 并将 retryNotified 重置移到触发拉取之前 --- frontend/src/views/SearchView.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/SearchView.vue b/frontend/src/views/SearchView.vue index 596eebd..1e5744f 100644 --- a/frontend/src/views/SearchView.vue +++ b/frontend/src/views/SearchView.vue @@ -306,6 +306,7 @@ function closePullLoading() { async function doPkgPull() { const pp = state.pkgPullProgress if (pp.running) return + retryNotified = false const res = await triggerPkgPull() if (!res || !res.ok) return if (res.demo) { @@ -317,17 +318,18 @@ async function doPkgPull() { await refreshPkgList() return } - retryNotified = false closePullLoading() pullLoading.value = ElMessage({ type: 'loading', message: '正在拉取npm包…', duration: 0 }) // 任务已进入后台执行,进度由 store 轮询更新(running … done),不阻塞当前操作 } -// 重试轮次变化(round ≥ 2 表示第一次重试开始)→ 轻量提示 +// 重试轮次变化(round ≥ 2 表示进入重试轮)→ 轻量提示 +// 必须仍在拉取中(running)才提示:拉取瞬间完成时,同一轮询会同时带回 +// round≥2 与 running=false(结束时的轮次回填),不能误判为「开始重试」 watch( () => state.pkgPullProgress.round, (round) => { - if (round >= 2 && !retryNotified) { + if (round >= 2 && !retryNotified && state.pkgPullProgress.running) { retryNotified = true closePullLoading() pullLoading.value = ElMessage({ type: 'loading', message: '正在重新拉取npm包…', duration: 0 })