update:语音优化
This commit is contained in:
@@ -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();
|
||||
@@ -26,6 +27,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);
|
||||
@@ -34,7 +36,7 @@ const updateTimer = (value) => {
|
||||
count.value = Math.round(value);
|
||||
};
|
||||
onMounted(() => {
|
||||
audioManager.play("请射箭测试距离");
|
||||
audioManager.play("请射箭!测试站距与靶纸");
|
||||
if (props.isBattle) {
|
||||
timer.value = setInterval(() => {
|
||||
count.value -= 1;
|
||||
@@ -51,14 +53,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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,13 +101,12 @@ onBeforeUnmount(() => {
|
||||
模拟射箭
|
||||
</button>
|
||||
<view class="warnning-text">
|
||||
<block v-if="distance > 0">
|
||||
<text>当前距离{{ distance }}米</text>
|
||||
<text v-if="distance >= 5">已达到距离要求</text>
|
||||
<text v-else>请调整站位</text>
|
||||
<block v-if="statusText">
|
||||
<text v-if="distance > 0">当前距离{{ distance }}米</text>
|
||||
<text>{{ statusText }}</text>
|
||||
</block>
|
||||
<block v-else>
|
||||
<text>请射箭,测试站距</text>
|
||||
<text>请射箭,测试站距与靶纸</text>
|
||||
</block>
|
||||
</view>
|
||||
<view class="user-row">
|
||||
|
||||
Reference in New Issue
Block a user