update:语音优化

This commit is contained in:
2026-08-19 14:04:12 +08:00
parent 75cfcd66ee
commit bb224c9f29
13 changed files with 153 additions and 86 deletions
+10 -11
View File
@@ -6,6 +6,7 @@ import Avatar from "@/components/Avatar.vue";
import audioManager from "@/audioManager";
import { simulShootAPI } from "@/apis";
import { MESSAGETYPESV2 } from "@/constants";
import { getDistanceCheckAudioKey, getDistanceCheckText } from "@/util";
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
@@ -30,6 +31,7 @@ const props = defineProps({
});
const arrow = ref({});
const distance = ref(0);
const statusText = ref("");
const showsimul = ref(false);
const count = ref(props.count);
const timer = ref(null);
@@ -38,7 +40,7 @@ const updateTimer = (value) => {
count.value = Math.round(value);
};
onMounted(() => {
audioManager.play("请射箭测试距离");
audioManager.play("请射箭测试站距与靶纸");
if (props.isBattle) {
timer.value = setInterval(() => {
count.value -= 1;
@@ -55,14 +57,12 @@ onBeforeUnmount(() => {
async function onReceiveMessage(msg) {
if (Array.isArray(msg)) return;
if (msg.type === MESSAGETYPESV2.TestDistance) {
const rawDistance = Number(msg.shootData?.distance);
const rawDistance = Number(msg.shootData?.distance ?? msg.shootData?.dst);
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("距离不足");
statusText.value = getDistanceCheckText(msg.shootData);
audioManager.play(getDistanceCheckAudioKey(msg.shootData));
}
}
@@ -100,13 +100,12 @@ onBeforeUnmount(() => {
</button>
<view class="warnning-text">
<view class="target-tip">当前靶纸为<text class="text-yellow">{{ targetType }}cm</text>全环靶</view>
<block v-if="distance > 0">
<text>当前距离<text class="text-yellow">{{ distance }}</text></text>
<text v-if="distance >= 5">已达到距离要求</text>
<text v-else>请调整站位</text>
<block v-if="statusText">
<text v-if="distance > 0">当前距离<text class="text-yellow">{{ distance }}</text></text>
<text>{{ statusText }}</text>
</block>
<block v-else>
<text>请射箭测试站距</text>
<text>请射箭测试站距与靶纸</text>
</block>
</view>
<view class="user-row">