diff --git a/src/components/HeaderProgress.vue b/src/components/HeaderProgress.vue index da96697..b4bd643 100644 --- a/src/components/HeaderProgress.vue +++ b/src/components/HeaderProgress.vue @@ -19,12 +19,17 @@ const ended = ref(false); const halfTime = ref(false); const currentShot = ref(0); const totalShot = ref(0); +/** 标记组件是否已完成挂载,防止 immediate watcher 在挂载前用旧 store 值触发意外播音 */ +const isMounted = ref(false); watch( () => tips.value, (newVal) => { + // 挂载完成前不播音(避免 immediate store watcher 用旧值触发多余播报) + if (!isMounted.value) return; + // 空字符串或含"重回"的 tips 均不播音 + if (!newVal || newVal.includes("重回")) return; let key = []; - if (newVal.includes("重回")) return; if (currentRoundEnded.value) { // 播放当前轮次语音 key.push(`第${["一", "二", "三", "四", "五"][currentRound.value]}轮`); @@ -113,6 +118,7 @@ watch(() => store.game.tips, (newVal) => { }, { immediate: true }); onMounted(() => { + isMounted.value = true; uni.$on("update-tips", onUpdateTips); uni.$on("socket-inbox", onReceiveMessage); uni.$on("play-sound", playSound); diff --git a/src/pages/friend-battle.vue b/src/pages/friend-battle.vue index 698524a..62e2fd7 100644 --- a/src/pages/friend-battle.vue +++ b/src/pages/friend-battle.vue @@ -98,8 +98,10 @@ onLoad(async (options) => { - 约上朋友开几局,欢乐多,不寂寞 - 一起练升级更快,早日加入全国排位赛! + + 约上朋友开几局,欢乐多,不寂寞 + 一起练升级更快,早日加入全国排位赛! + @@ -171,6 +173,24 @@ onLoad(async (options) => {