From c298e258cc75c493d4832382ec7d6c162e3e421c Mon Sep 17 00:00:00 2001 From: chenlimao Date: Wed, 13 May 2026 13:42:22 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BC=98=E5=8C=96=E6=AF=94?= =?UTF-8?q?=E8=B5=9Btips=E5=B1=95=E7=A4=BA=E9=80=BB=E8=BE=91?= 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 | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/HeaderProgress.vue b/src/components/HeaderProgress.vue index 0b9aaad..522f75c 100644 --- a/src/components/HeaderProgress.vue +++ b/src/components/HeaderProgress.vue @@ -60,7 +60,8 @@ async function onReceiveMessage(message) { audioManager.play("比赛结束", false); } else if (type === MESSAGETYPESV2.ShootResult) { if (melee.value && current.playerId !== user.value.id) return; - if (current.playerId === user.value.id) currentShot.value++; + // 仅计用户自己的命中箭,并加上限防护,防止超过 totalShot(如重入时 currentShot 初始值偏高) + if (current.playerId === user.value.id && currentShot.value < totalShot.value) currentShot.value++; if (message.shootData) { let key = []; key.push( diff --git a/src/pages/team-battle.vue b/src/pages/team-battle.vue index daab6aa..56ae0b6 100644 --- a/src/pages/team-battle.vue +++ b/src/pages/team-battle.vue @@ -250,8 +250,9 @@ async function onReceiveMessage(msg) { onLoad(async (options) => { if (options.battleId) battleId.value = options.battleId; - // 重置箭数,防止因 Pinia 保留上一场比赛的旧值而错误展示 + // 重置箭数和提示文案,防止因 Pinia 保留上一场比赛的旧值而错误展示 store.updateShotInfo(0, 0); + store.updateTips(""); // uni.enableAlertBeforeUnload({ // message: "离开比赛可能导致比赛失败,是否继续?", // success: (res) => { @@ -290,8 +291,9 @@ onShow(async () => { if (result.status !== 0) { // 比赛进行中,从后端恢复箭数(测距阶段不展示) if (result.shootNumber) { - // current.index 为 0 基的当前箭序号(0=第一箭),+1 后作为 currentShot 展示 - store.updateShotInfo((result.current?.index ?? 0) + 1, result.shootNumber); + // current.index 为 0 基的已射箭数(0=尚未射出),与 ShootResult 累加语义一致 + // 注意:不再 +1,避免重进时与后续 ShootResult 自增形成双重计数导致超出 totalShot + store.updateShotInfo(result.current?.index ?? 0, result.shootNumber); } } else { // 测距阶段重置箭数,防止 ImmediateWatcher 读取 Pinia 保留的旧值