fix(pkglist): 拉取瞬间完成时不再误弹「正在重新拉取」提示
CI / Backend tests (push) Canceled after 0s
CI / Frontend build (push) Canceled after 0s

同一轮询同时带回 round≥2 与 running=false 时,轮次 watcher 误判为开始重试,
导致「正在重新拉取」与「拉取完成」两条提示同屏出现;增加 running 守卫,
并将 retryNotified 重置移到触发拉取之前
This commit is contained in:
陈银军
2026-09-21 23:21:46 +08:00
parent da924492ce
commit a598fac255
+5 -3
View File
@@ -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 })