Merge branch 'new-race-mode' into test
This commit is contained in:
@@ -105,8 +105,9 @@ watch(() => store.game.totalShot, (newVal) => {
|
|||||||
|
|
||||||
// 监听 Pinia store 中 tips 变化,用于比赛恢复时同步提示文案(替代 uni.$emit 避免时序问题)
|
// 监听 Pinia store 中 tips 变化,用于比赛恢复时同步提示文案(替代 uni.$emit 避免时序问题)
|
||||||
// 使用 immediate: true 确保组件创建时立即读取 store 当前值(解决 onShow 早于 onMounted 导致 uni.$emit 事件丢失的问题)
|
// 使用 immediate: true 确保组件创建时立即读取 store 当前值(解决 onShow 早于 onMounted 导致 uni.$emit 事件丢失的问题)
|
||||||
|
// 注意:使用 != null 而非 if(newVal),确保空字符串 "" 也能触发清空(避免重新开赛时旧文案残留)
|
||||||
watch(() => store.game.tips, (newVal) => {
|
watch(() => store.game.tips, (newVal) => {
|
||||||
if (newVal) {
|
if (newVal != null) {
|
||||||
tips.value = newVal;
|
tips.value = newVal;
|
||||||
}
|
}
|
||||||
}, { immediate: true });
|
}, { immediate: true });
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ const battleWay = ref(0);
|
|||||||
const lastToSomeoneShootKey = ref("");
|
const lastToSomeoneShootKey = ref("");
|
||||||
/** 控制设备离线提示弹窗的显示状态 */
|
/** 控制设备离线提示弹窗的显示状态 */
|
||||||
const showOfflineModal = ref(false);
|
const showOfflineModal = ref(false);
|
||||||
|
/** 待延迟发出的进度条重置队伍(ShootResult 报环期间暂缓切换,报环音频结束后再发 reset) */
|
||||||
|
const pendingProgressTeam = ref(null);
|
||||||
|
/** 报环序列的最后一个音频类型('hasAdjust' = 最后 key 为方向调整,'noAdjust' = 最后 key 为环数/未上靶) */
|
||||||
|
const pendingTriggerKey = ref(null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监听设备在线状态,比赛进行中设备离线时弹窗提示用户
|
* 监听设备在线状态,比赛进行中设备离线时弹窗提示用户
|
||||||
@@ -144,7 +148,8 @@ const recoverData = (battleInfo, {force = false, arrowOnly = false} = {}) => {
|
|||||||
}, 100);
|
}, 100);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
uni.$emit("update-remain", {reset: true, value: 15, team: targetTeam});
|
// 报环语音播放期间暂缓切换进度条:存储目标队伍,待报环音频结束后由 onAudioEnded 发出 reset
|
||||||
|
pendingProgressTeam.value = targetTeam;
|
||||||
updateRemainSecond.value = battleInfo.readyTime;
|
updateRemainSecond.value = battleInfo.readyTime;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -165,6 +170,20 @@ const recoverData = (battleInfo, {force = false, arrowOnly = false} = {}) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function onAudioEnded(s) {
|
function onAudioEnded(s) {
|
||||||
|
// 报环序列最后一个音频结束后,切换进度条到下一玩家满值
|
||||||
|
// pendingTriggerKey 标记最后一个 key 类型:hasAdjust 则等"调整"音频结束,noAdjust 则等"环"/"靶"音频结束
|
||||||
|
if (
|
||||||
|
pendingProgressTeam.value !== null &&
|
||||||
|
pendingTriggerKey.value !== null &&
|
||||||
|
(
|
||||||
|
(pendingTriggerKey.value === 'hasAdjust' && s.includes('调整')) ||
|
||||||
|
(pendingTriggerKey.value === 'noAdjust' && (s.includes('环') || s.includes('靶')))
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
uni.$emit("update-remain", {reset: true, value: 15, team: pendingProgressTeam.value});
|
||||||
|
pendingProgressTeam.value = null;
|
||||||
|
pendingTriggerKey.value = null;
|
||||||
|
}
|
||||||
// "请红方射箭"/"请蓝方射箭":队友或对手轮次;"轮到你了":用户本人轮次(HeaderProgress特殊分支)
|
// "请红方射箭"/"请蓝方射箭":队友或对手轮次;"轮到你了":用户本人轮次(HeaderProgress特殊分支)
|
||||||
// 三者音频结束后均需启动倒计时进度条
|
// 三者音频结束后均需启动倒计时进度条
|
||||||
if (s.indexOf('请红方射箭') >= 0 || s.indexOf('请蓝方射箭') >= 0 || s.indexOf('轮到你了') >= 0) {
|
if (s.indexOf('请红方射箭') >= 0 || s.indexOf('请蓝方射箭') >= 0 || s.indexOf('轮到你了') >= 0) {
|
||||||
@@ -172,6 +191,12 @@ function onAudioEnded(s) {
|
|||||||
if (s.indexOf('请红方射箭') >= 0) team = 'red';
|
if (s.indexOf('请红方射箭') >= 0) team = 'red';
|
||||||
else if (s.indexOf('请蓝方射箭') >= 0) team = 'blue';
|
else if (s.indexOf('请蓝方射箭') >= 0) team = 'blue';
|
||||||
else team = tips.value.includes('红队') ? 'red' : 'blue'; // 轮到你了:从当前tips判断用户所在队伍
|
else team = tips.value.includes('红队') ? 'red' : 'blue'; // 轮到你了:从当前tips判断用户所在队伍
|
||||||
|
// 兜底:无报环音频时(如首次 ToSomeoneShoot 无前置 ShootResult),在此清空 pending 并发出 reset
|
||||||
|
if (pendingProgressTeam.value !== null) {
|
||||||
|
uni.$emit("update-remain", {reset: true, value: 15, team: pendingProgressTeam.value});
|
||||||
|
pendingProgressTeam.value = null;
|
||||||
|
pendingTriggerKey.value = null;
|
||||||
|
}
|
||||||
uni.$emit("update-remain", {stop: false, value: updateRemainSecond.value, team: team});
|
uni.$emit("update-remain", {stop: false, value: updateRemainSecond.value, team: team});
|
||||||
}
|
}
|
||||||
if (s.indexOf("比赛结束") >= 0) {
|
if (s.indexOf("比赛结束") >= 0) {
|
||||||
@@ -229,6 +254,11 @@ async function onReceiveMessage(msg) {
|
|||||||
uni.$emit("update-remain", {stop: true})
|
uni.$emit("update-remain", {stop: true})
|
||||||
showRoundTip.value = false;
|
showRoundTip.value = false;
|
||||||
recoverData(msg, {arrowOnly: true});
|
recoverData(msg, {arrowOnly: true});
|
||||||
|
// 根据 shootData.angle 预判报环序列最后一个 key:
|
||||||
|
// 有 angle 则最后 key 为"向X调整"(hasAdjust),否则为"环"/"未上靶"(noAdjust)
|
||||||
|
if (msg.shootData) {
|
||||||
|
pendingTriggerKey.value = (msg.shootData.angle !== null) ? 'hasAdjust' : 'noAdjust';
|
||||||
|
}
|
||||||
} else if (msg.type === MESSAGETYPESV2.NewRound) {
|
} else if (msg.type === MESSAGETYPESV2.NewRound) {
|
||||||
// 在进入延迟前先捕获当前轮次,供 onNewRound 使用,防止 800ms 内 ToSomeoneShoot 提前更新 currentRound 造成 Tip 展示错轮
|
// 在进入延迟前先捕获当前轮次,供 onNewRound 使用,防止 800ms 内 ToSomeoneShoot 提前更新 currentRound 造成 Tip 展示错轮
|
||||||
const prevRound = currentRound.value;
|
const prevRound = currentRound.value;
|
||||||
@@ -295,8 +325,11 @@ onShow(async () => {
|
|||||||
store.updateShotInfo(result.current?.indexMap?.[user.value.id] ?? 0, result.shootNumber);
|
store.updateShotInfo(result.current?.indexMap?.[user.value.id] ?? 0, result.shootNumber);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 测距阶段重置箭数,防止 ImmediateWatcher 读取 Pinia 保留的旧值
|
// 测距阶段重置箭数和提示文案,防止 ImmediateWatcher 读取 Pinia 保留的旧值
|
||||||
store.updateShotInfo(0, 0);
|
store.updateShotInfo(0, 0);
|
||||||
|
// 同步清空 Pinia tips 与本地 tips,避免重新开赛时 HeaderProgress 展示上一场旧文案
|
||||||
|
store.updateTips("");
|
||||||
|
tips.value = "";
|
||||||
}
|
}
|
||||||
recoverData(result, {force: true});
|
recoverData(result, {force: true});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user