fix:优化比赛tips展示逻辑
This commit is contained in:
@@ -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 保留的旧值
|
||||
|
||||
Reference in New Issue
Block a user