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); 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;
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) { if (message.shootData) {
let key = []; let key = [];
key.push( key.push(

View File

@@ -250,8 +250,9 @@ async function onReceiveMessage(msg) {
onLoad(async (options) => { onLoad(async (options) => {
if (options.battleId) battleId.value = options.battleId; if (options.battleId) battleId.value = options.battleId;
// 重置箭数,防止因 Pinia 保留上一场比赛的旧值而错误展示 // 重置箭数和提示文案,防止因 Pinia 保留上一场比赛的旧值而错误展示
store.updateShotInfo(0, 0); store.updateShotInfo(0, 0);
store.updateTips("");
// uni.enableAlertBeforeUnload({ // uni.enableAlertBeforeUnload({
// message: "离开比赛可能导致比赛失败,是否继续?", // message: "离开比赛可能导致比赛失败,是否继续?",
// success: (res) => { // success: (res) => {
@@ -290,8 +291,9 @@ onShow(async () => {
if (result.status !== 0) { if (result.status !== 0) {
// 比赛进行中,从后端恢复箭数(测距阶段不展示) // 比赛进行中,从后端恢复箭数(测距阶段不展示)
if (result.shootNumber) { if (result.shootNumber) {
// current.index 为 0 基的当前箭序号0=第一箭),+1 后作为 currentShot 展示 // current.index 为 0 基的已射箭数0=尚未射出),与 ShootResult 累加语义一致
store.updateShotInfo((result.current?.index ?? 0) + 1, result.shootNumber); // 注意:不再 +1避免重进时与后续 ShootResult 自增形成双重计数导致超出 totalShot
store.updateShotInfo(result.current?.index ?? 0, result.shootNumber);
} }
} else { } else {
// 测距阶段重置箭数,防止 ImmediateWatcher 读取 Pinia 保留的旧值 // 测距阶段重置箭数,防止 ImmediateWatcher 读取 Pinia 保留的旧值