From 6db2142cf654546794e5ad3ce43998166b476f82 Mon Sep 17 00:00:00 2001 From: chenlimao Date: Wed, 13 May 2026 15:40:12 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E6=B5=8B?= =?UTF-8?q?=E8=B7=9D=E9=A1=B5=E9=9D=A2=E6=A0=87=E9=A2=98=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/HeaderProgress.vue | 3 ++- src/pages/team-battle.vue | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/HeaderProgress.vue b/src/components/HeaderProgress.vue index c06c1d3..da96697 100644 --- a/src/components/HeaderProgress.vue +++ b/src/components/HeaderProgress.vue @@ -105,8 +105,9 @@ watch(() => store.game.totalShot, (newVal) => { // 监听 Pinia store 中 tips 变化,用于比赛恢复时同步提示文案(替代 uni.$emit 避免时序问题) // 使用 immediate: true 确保组件创建时立即读取 store 当前值(解决 onShow 早于 onMounted 导致 uni.$emit 事件丢失的问题) +// 注意:使用 != null 而非 if(newVal),确保空字符串 "" 也能触发清空(避免重新开赛时旧文案残留) watch(() => store.game.tips, (newVal) => { - if (newVal) { + if (newVal != null) { tips.value = newVal; } }, { immediate: true }); diff --git a/src/pages/team-battle.vue b/src/pages/team-battle.vue index 06750f9..34802a4 100644 --- a/src/pages/team-battle.vue +++ b/src/pages/team-battle.vue @@ -295,8 +295,11 @@ onShow(async () => { store.updateShotInfo(result.current?.indexMap?.[user.value.id] ?? 0, result.shootNumber); } } else { - // 测距阶段重置箭数,防止 ImmediateWatcher 读取 Pinia 保留的旧值 + // 测距阶段重置箭数和提示文案,防止 ImmediateWatcher 读取 Pinia 保留的旧值 store.updateShotInfo(0, 0); + // 同步清空 Pinia tips 与本地 tips,避免重新开赛时 HeaderProgress 展示上一场旧文案 + store.updateTips(""); + tips.value = ""; } recoverData(result, {force: true}); }