From 3ab1ad59bdc98175a18d1fcdd3bf0bcd4d0cafd1 Mon Sep 17 00:00:00 2001 From: zhangyibo95 <690096405@qq.com> Date: Fri, 31 Jul 2026 14:45:17 +0800 Subject: [PATCH] =?UTF-8?q?update:=E6=96=B0=E5=A2=9E=E8=AF=AD=E9=9F=B3?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 10 ++++++++-- src/audioManager.js | 9 +++++++++ src/components/TestDistance.vue | 9 +++++++-- src/matchWebsocket.js | 1 + src/pages/first-try.vue | 5 ++++- src/pages/team-battle/components/TestDistance.vue | 9 +++++++-- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/App.vue b/src/App.vue index 608b1ec..1b364ec 100644 --- a/src/App.vue +++ b/src/App.vue @@ -21,7 +21,9 @@ import audioManager from "./audioManager"; const store = useStore(); const { - user + user, + device, + online } = storeToRefs(store); const { updateUser, @@ -68,7 +70,11 @@ async function emitUpdateOnline() { const data = await getDeviceBatteryAPI(); - updateOnline(data.online); + const wasOnline = Boolean(online.value); + const nextOnline = Boolean(data.online); + updateOnline(nextOnline); + if (!device.value.deviceId || wasOnline === nextOnline) return; + audioManager.play(nextOnline ? "设备已连接" : "设备连接已断开"); } function onDeviceBindInvalid() { diff --git a/src/audioManager.js b/src/audioManager.js index 81cc841..1bf8f31 100644 --- a/src/audioManager.js +++ b/src/audioManager.js @@ -4,6 +4,10 @@ export const AUDIO_INTERRUPTION_END_EVENT = "audio-interruption-end"; export const audioFils = { tententen: "https://static.shelingxingqiu.com/shootmini/static/audio/tententen.mp3", 点击按钮: "https://static.shelingxingqiu.com/shootmini/static/audio/%E7%82%B9%E5%87%BB%E6%8C%89%E9%92%AE.mp3", + 设备连接已断开: + "https://static.shelingxingqiu.com/shootmini/static/audio/%E8%AE%BE%E5%A4%87%E8%BF%9E%E6%8E%A5%E5%B7%B2%E6%96%AD%E5%BC%80.MP3", + 设备已连接: + "https://static.shelingxingqiu.com/shootmini/static/audio/%E8%AE%BE%E5%A4%87%E5%B7%B2%E8%BF%9E%E6%8E%A5.MP3", "20CM全环靶": "https://static.shelingxingqiu.com/shootmini/static/audio/20CM%E5%85%A8%E7%8E%AF%E9%9D%B6-%E6%97%A0%E6%95%88.mp3", "40CM全环靶": "https://static.shelingxingqiu.com/shootmini/static/audio/40CM%E5%85%A8%E7%8E%AF%E9%9D%B6-%E6%97%A0%E6%95%88.mp3", // 激光已校准: @@ -16,6 +20,8 @@ export const audioFils = { "https://static.shelingxingqiu.com/attachment/2025-09-17/dcutwrda0amn5kqr4j.mp3", 距离不足: "https://static.shelingxingqiu.com/attachment/2025-11-12/de6hr2faw28t0ianh0.mp3", + "未发现靶纸,请瞄准靶纸射箭": + "https://static.shelingxingqiu.com/shootmini/static/audio/%E6%9C%AA%E5%8F%91%E7%8E%B0%E9%9D%B6%E7%BA%B8%EF%BC%8C%E8%AF%B7%E7%9E%84%E5%87%86%E9%9D%B6%E7%BA%B8%E5%B0%84%E7%AE%AD.MP3", 轮到你了: "https://static.shelingxingqiu.com/attachment/2025-09-17/dcutzdrn4lxcpv8aqr.mp3", 第一轮: @@ -102,6 +108,8 @@ const AUDIO_WARM_CONCURRENCY = 3; const AUDIO_WARM_RETRIES = 1; const AUDIO_WARM_PRIORITY_KEYS = [ "点击按钮", + "设备连接已断开", + "设备已连接", "比赛开始", "练习开始", "练习结束", @@ -116,6 +124,7 @@ const AUDIO_WARM_PRIORITY_KEYS = [ "请红方射箭", "距离合格", "距离不足", + "未发现靶纸,请瞄准靶纸射箭", "未上靶", "X环", ]; diff --git a/src/components/TestDistance.vue b/src/components/TestDistance.vue index f75de58..385ee5e 100644 --- a/src/components/TestDistance.vue +++ b/src/components/TestDistance.vue @@ -51,8 +51,13 @@ onBeforeUnmount(() => { async function onReceiveMessage(msg) { if (Array.isArray(msg)) return; if (msg.type === MESSAGETYPESV2.TestDistance) { - distance.value = Number((msg.shootData.distance / 100).toFixed(2)); - if (distance.value >= 5) audioManager.play("距离合格"); + const rawDistance = Number(msg.shootData?.distance); + distance.value = Number.isFinite(rawDistance) + ? Number((rawDistance / 100).toFixed(2)) + : 0; + if (rawDistance === 0) { + audioManager.play("未发现靶纸,请瞄准靶纸射箭"); + } else if (distance.value >= 5) audioManager.play("距离合格"); else audioManager.play("距离不足"); } } diff --git a/src/matchWebsocket.js b/src/matchWebsocket.js index cc0b803..91dbb15 100644 --- a/src/matchWebsocket.js +++ b/src/matchWebsocket.js @@ -319,6 +319,7 @@ function getShootResultAudioKeys(shootData) { function getTestDistanceAudioKeys(shootData) { const distance = Number(shootData?.distance ?? shootData?.dst); if (Number.isNaN(distance)) return []; + if (distance === 0) return ["未发现靶纸,请瞄准靶纸射箭"]; return [distance / 100 >= 5 ? "\u8ddd\u79bb\u5408\u683c" : "\u8ddd\u79bb\u4e0d\u8db3"]; } diff --git a/src/pages/first-try.vue b/src/pages/first-try.vue index eef6bb7..4cbb378 100644 --- a/src/pages/first-try.vue +++ b/src/pages/first-try.vue @@ -154,7 +154,10 @@ async function onReceiveMessage(msg) { } else if (msg.type === MESSAGETYPESV2.BattleEnd) { setTimeout(() => onOver(msg), 1500); } else if (msg.type === MESSAGETYPESV2.TestDistance && step.value === 3) { - if (msg.shootData.distance / 100 >= 5) { + const rawDistance = Number(msg.shootData?.distance); + if (rawDistance === 0) { + audioManager.play("未发现靶纸,请瞄准靶纸射箭"); + } else if (rawDistance / 100 >= 5) { audioManager.play("距离合格"); btnDisabled.value = false; showGuide.value = true; diff --git a/src/pages/team-battle/components/TestDistance.vue b/src/pages/team-battle/components/TestDistance.vue index c2b4b4c..4ff422b 100644 --- a/src/pages/team-battle/components/TestDistance.vue +++ b/src/pages/team-battle/components/TestDistance.vue @@ -51,8 +51,13 @@ onBeforeUnmount(() => { async function onReceiveMessage(msg) { if (Array.isArray(msg)) return; if (msg.type === MESSAGETYPESV2.TestDistance) { - distance.value = Number((msg.shootData.distance / 100).toFixed(2)); - if (distance.value >= 5) audioManager.play("距离合格"); + const rawDistance = Number(msg.shootData?.distance); + distance.value = Number.isFinite(rawDistance) + ? Number((rawDistance / 100).toFixed(2)) + : 0; + if (rawDistance === 0) { + audioManager.play("未发现靶纸,请瞄准靶纸射箭"); + } else if (distance.value >= 5) audioManager.play("距离合格"); else audioManager.play("距离不足"); } }