添加校准声音

This commit is contained in:
kron
2025-10-29 18:07:42 +08:00
parent f5d5475ee4
commit 84cdbb94db
5 changed files with 54 additions and 18 deletions

View File

@@ -1,4 +1,6 @@
const audioFils = { const audioFils = {
激光已校准:
"https://static.shelingxingqiu.com/attachment/2025-10-29/ddupaur1vdkyhzaqdc.mp3",
胜利: "https://static.shelingxingqiu.com/attachment/2025-09-17/dcuo9yjp0kt5msvmvd.mp3", 胜利: "https://static.shelingxingqiu.com/attachment/2025-09-17/dcuo9yjp0kt5msvmvd.mp3",
失败: "https://static.shelingxingqiu.com/attachment/2025-09-17/dcuo9yht2sdwhuqygy.mp3", 失败: "https://static.shelingxingqiu.com/attachment/2025-09-17/dcuo9yht2sdwhuqygy.mp3",
请射箭测试距离: 请射箭测试距离:
@@ -66,7 +68,7 @@ function debugLog(...args) {
const envVersion = accountInfo.miniProgram.envVersion; const envVersion = accountInfo.miniProgram.envVersion;
// 只在体验版打印日志,正式版(release)和开发版(develop)不打印 // 只在体验版打印日志,正式版(release)和开发版(develop)不打印
if (envVersion === 'trial') { if (envVersion === "trial") {
console.log(...args); console.log(...args);
} }
} }
@@ -116,7 +118,11 @@ class AudioManager {
} }
const key = this.audioKeys[this.currentLoadingIndex]; const key = this.audioKeys[this.currentLoadingIndex];
debugLog(`开始加载音频 ${this.currentLoadingIndex + 1}/${this.audioKeys.length}: ${key}`); debugLog(
`开始加载音频 ${this.currentLoadingIndex + 1}/${
this.audioKeys.length
}: ${key}`
);
this.createAudio(key, () => { this.createAudio(key, () => {
this.currentLoadingIndex++; this.currentLoadingIndex++;
@@ -187,7 +193,9 @@ class AudioManager {
this.retryLoadAudio(key); this.retryLoadAudio(key);
}, 1000); }, 1000);
} else { } else {
console.error(`音频 ${key} 重试 ${this.maxRetries} 次后仍然失败,停止重试`); console.error(
`音频 ${key} 重试 ${this.maxRetries} 次后仍然失败,停止重试`
);
const failedAudio = this.audioMap.get(key); const failedAudio = this.audioMap.get(key);
if (failedAudio) { if (failedAudio) {
failedAudio.destroy(); failedAudio.destroy();

View File

@@ -6,6 +6,8 @@ const power = ref(0);
const timer = ref(null); const timer = ref(null);
onMounted(async () => { onMounted(async () => {
const data = await getDeviceBatteryAPI();
power.value = data.battery;
timer.value = setInterval(async () => { timer.value = setInterval(async () => {
const data = await getDeviceBatteryAPI(); const data = await getDeviceBatteryAPI();
power.value = data.battery; power.value = data.battery;

View File

@@ -24,6 +24,7 @@ export const MESSAGETYPES = {
LvlUpdate: 3958625354, LvlUpdate: 3958625354,
TeamUpdate: 4168086616, TeamUpdate: 4168086616,
InvalidShot: 4168086617, InvalidShot: 4168086617,
Calibration: 4168086625,
}; };
export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"]; export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"];

View File

@@ -1,9 +1,11 @@
<script setup> <script setup>
import { ref, onMounted } from "vue"; import { ref, onMounted, onBeforeUnmount } from "vue";
import Container from "@/components/Container.vue"; import Container from "@/components/Container.vue";
import SButton from "@/components/SButton.vue"; import SButton from "@/components/SButton.vue";
import { laserAimAPI, laserCloseAPI } from "@/apis"; import { laserAimAPI, laserCloseAPI } from "@/apis";
import { MESSAGETYPES } from "@/constants";
import audioManager from "@/audioManager";
const guides = [ const guides = [
{ {
@@ -20,15 +22,32 @@ const guides = [
}, },
]; ];
const done = ref(false);
const onComplete = async () => { const onComplete = async () => {
await laserCloseAPI(); await laserCloseAPI();
uni.setStorageSync("calibration", true);
uni.navigateBack(); uni.navigateBack();
}; };
function onReceiveMessage(messages = []) {
messages.forEach((msg) => {
if (msg.constructor === MESSAGETYPES.Calibration) {
done.value = true;
uni.setStorageSync("calibration", true);
audioManager.play("激光已校准");
}
});
}
onMounted(async () => { onMounted(async () => {
uni.$on("socket-inbox", onReceiveMessage);
await laserAimAPI(); await laserAimAPI();
}); });
onBeforeUnmount(async () => {
uni.$off("socket-inbox", onReceiveMessage);
await laserCloseAPI();
});
</script> </script>
<template> <template>
@@ -42,7 +61,12 @@ onMounted(async () => {
<image :src="guide.src" mode="widthFix" /> <image :src="guide.src" mode="widthFix" />
</view> </view>
<text>请完成以上步骤校准智能弓</text> <text>请完成以上步骤校准智能弓</text>
<SButton :onClick="onComplete" width="60vw" :rounded="40"> <SButton
:onClick="onComplete"
width="60vw"
:rounded="40"
:disabled="!done"
>
我已校准 我已校准
</SButton> </SButton>
</view> </view>

View File

@@ -78,6 +78,7 @@ const toFristTryPage = () => {
const unbindDevice = async () => { const unbindDevice = async () => {
await unbindDeviceAPI(device.value.deviceId); await unbindDeviceAPI(device.value.deviceId);
uni.setStorageSync("calibration", false);
uni.showToast({ uni.showToast({
title: "解绑成功", title: "解绑成功",
icon: "success", icon: "success",
@@ -203,10 +204,6 @@ onShow(() => {
<text>{{ user.nickName }}</text> <text>{{ user.nickName }}</text>
</view> </view>
</view> </view>
<view v-if="!calibration">
<text>恭喜你的弓箭和账号已成功绑定</text>
<text :style="{ color: '#fed847' }">已赠送6个月射灵世界会员</text>
</view>
<block v-if="calibration"> <block v-if="calibration">
<SButton :onClick="toFristTryPage" width="60vw" :rounded="40" <SButton :onClick="toFristTryPage" width="60vw" :rounded="40"
>进入新手试炼</SButton >进入新手试炼</SButton
@@ -223,6 +220,10 @@ onShow(() => {
</view> </view>
</block> </block>
<block v-else> <block v-else>
<view>
<text>恭喜你的弓箭和账号已成功绑定</text>
<text :style="{ color: '#fed847' }">已赠送6个月射灵世界会员</text>
</view>
<SButton :onClick="goCalibration" width="60vw" :rounded="40"> <SButton :onClick="goCalibration" width="60vw" :rounded="40">
校准智能弓 校准智能弓
</SButton> </SButton>
@@ -236,7 +237,7 @@ onShow(() => {
<view @click="toDeviceIntroPage"> <view @click="toDeviceIntroPage">
<image src="../static/device-icon.png" mode="widthFix" /> <image src="../static/device-icon.png" mode="widthFix" />
<text>{{ device.deviceName }}</text> <text>{{ device.deviceName }}</text>
<view class="calibration" v-if="calibration"> <view class="calibration">
<button hover-class="none" @click="goCalibration"> <button hover-class="none" @click="goCalibration">
<text>去校准</text> <text>去校准</text>
<image src="../static/enter-arrow-blue.png" mode="widthFix" /> <image src="../static/enter-arrow-blue.png" mode="widthFix" />