fix:比赛射箭数改为用indexMap字段展示

This commit is contained in:
2026-05-13 15:14:53 +08:00
parent 4761206a6e
commit c3570afeba
2 changed files with 4 additions and 4 deletions

View File

@@ -60,8 +60,8 @@ async function onReceiveMessage(message) {
audioManager.play("比赛结束", false); audioManager.play("比赛结束", false);
} else if (type === MESSAGETYPESV2.ShootResult) { } else if (type === MESSAGETYPESV2.ShootResult) {
if (melee.value && current.playerId !== user.value.id) return; if (melee.value && current.playerId !== user.value.id) return;
// 直接使用后端返回的 myIndex当前用户已射箭数,不在前端自增 // 从 indexMap 按当前用户 id 取已射箭数,由后端维护准确值,不在前端自增
if (current.playerId === user.value.id) currentShot.value = current.myIndex ?? currentShot.value; if (current.playerId === user.value.id) currentShot.value = current.indexMap?.[user.value.id] ?? currentShot.value;
if (message.shootData) { if (message.shootData) {
let key = []; let key = [];
key.push( key.push(

View File

@@ -290,9 +290,9 @@ onShow(async () => {
} else { } else {
if (result.status !== 0) { if (result.status !== 0) {
// 比赛进行中,从后端恢复箭数(测距阶段不展示) // 比赛进行中,从后端恢复箭数(测距阶段不展示)
// 决金轮不展示箭数;其余轮次使用后端 myIndex 恢复已射箭数 // 决金轮不展示箭数;其余轮次从 indexMap 按用户 id 取已射箭数
if (result.shootNumber && !result.current?.goldRound) { if (result.shootNumber && !result.current?.goldRound) {
store.updateShotInfo(result.current?.myIndex ?? 0, result.shootNumber); store.updateShotInfo(result.current?.indexMap?.[user.value.id] ?? 0, result.shootNumber);
} }
} else { } else {
// 测距阶段重置箭数,防止 ImmediateWatcher 读取 Pinia 保留的旧值 // 测距阶段重置箭数,防止 ImmediateWatcher 读取 Pinia 保留的旧值