fix:优化比赛tips展示逻辑

This commit is contained in:
2026-05-13 13:42:22 +08:00
parent 6cb5288631
commit c298e258cc
2 changed files with 7 additions and 4 deletions

View File

@@ -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(

View File

@@ -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 保留的旧值