fix:修复重进比赛进度条丢失问题

This commit is contained in:
2026-05-13 10:49:37 +08:00
parent 996472953a
commit 6d434e89ab

View File

@@ -115,15 +115,29 @@ const recoverData = (battleInfo, {force = false, arrowOnly = false} = {}) => {
tips.value = nextTips; tips.value = nextTips;
uni.$emit("update-tips", nextTips); uni.$emit("update-tips", nextTips);
// redPlayer 已在上方 find() 确认:不为 null 则当前射手在红队 // redPlayer 已在上方 find() 确认:不为 null 则当前射手在红队
uni.$emit("update-remain", {reset: true, value: 15, team: redPlayer?'red':'blue'}); const targetTeam = redPlayer ? 'red' : 'blue';
if (force) { if (force) {
const remain = (Date.now() - battleInfo.current.startTime) / 1000; // force 模式下 start.value 刚由 null 变 trueVue 异步调度渲染,
console.log(`当前轮已进行${remain}`); // ShootProgress2v-if="start"尚未挂载update-remain 事件会被丢弃。
if (remain > 0 && remain < 15) { // 同时 HeaderProgress 对含"重回"的 tips 拦截音频,倒计时无法依赖
updateRemainSecond.value = 15 - remain - 0.2 // onAudioEnded 驱动,需在 nextTick 后直接启动。
const elapsed = (Date.now() - battleInfo.current.startTime) / 1000;
console.log(`当前轮已进行${elapsed}`);
if (elapsed > 0 && elapsed < 15) {
updateRemainSecond.value = 15 - elapsed - 0.2;
} }
const actualRemain = updateRemainSecond.value;
nextTick(() => {
// 等 ShootProgress2 挂载后再发重置事件,确保事件能被接收
uni.$emit("update-remain", {reset: true, value: 15, team: targetTeam});
// 重置动画完成后,直接启动倒计时(无需依赖音频结束回调)
setTimeout(() => {
uni.$emit("update-remain", {stop: false, value: actualRemain, team: targetTeam});
}, 100);
});
} else { } else {
updateRemainSecond.value = battleInfo.readyTime uni.$emit("update-remain", {reset: true, value: 15, team: targetTeam});
updateRemainSecond.value = battleInfo.readyTime;
} }
} else { } else {
currentRound.value = battleInfo.current.round || 1; currentRound.value = battleInfo.current.round || 1;