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/ScorePanel2.vue b/src/components/ScorePanel2.vue index bdd6c04..c12addd 100644 --- a/src/components/ScorePanel2.vue +++ b/src/components/ScorePanel2.vue @@ -5,13 +5,19 @@ const props = defineProps({ default: () => [], }, }); -const getSum = (a, b, c) => { - const sum = (Number(a) || 0) + (Number(b) || 0) + (Number(c) || 0); - return sum > 0 ? sum + "环" : "-"; +const getSum = (...arrows) => { + const recordedArrows = arrows.filter(Boolean); + if (!recordedArrows.length) return "-"; + const sum = recordedArrows.reduce( + (total, arrow) => total + (Number(arrow.ring) || 0), + 0 + ); + return `${sum}环`; }; const roundsName = ["第一轮", "第二轮", "第三轮", "第四轮"]; -const getShowText = (arrow = {}) => { - return arrow.ring ? (arrow.ringX ? "X" : arrow.ring + "环") : "-"; +const getShowText = (arrow) => { + if (!arrow) return "-"; + return arrow.ringX ? "X" : `${Number(arrow.ring) || 0}环`; };