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}); }