添加音频测试页面
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
const audioFils = {
|
export const audioFils = {
|
||||||
激光已校准:
|
激光已校准:
|
||||||
"https://static.shelingxingqiu.com/attachment/2025-10-29/ddupaur1vdkyhzaqdc.mp3",
|
"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",
|
||||||
@@ -168,6 +168,10 @@ class AudioManager {
|
|||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
clearTimeout(loadTimeout);
|
clearTimeout(loadTimeout);
|
||||||
debugLog(`音频 ${key} 已加载完成`);
|
debugLog(`音频 ${key} 已加载完成`);
|
||||||
|
uni.$emit("audioLoaded", key);
|
||||||
|
const loadedAudioKeys = uni.getStorageSync("loadedAudioKeys") || {};
|
||||||
|
loadedAudioKeys[key] = true;
|
||||||
|
uni.setStorageSync("loadedAudioKeys", loadedAudioKeys);
|
||||||
this.retryCount.set(key, 0);
|
this.retryCount.set(key, 0);
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
});
|
});
|
||||||
@@ -243,9 +247,9 @@ class AudioManager {
|
|||||||
|
|
||||||
const audio = this.audioMap.get(key);
|
const audio = this.audioMap.get(key);
|
||||||
if (audio) {
|
if (audio) {
|
||||||
console.log("播放音频:", key);
|
|
||||||
// 显式授权播放并立即播放
|
// 显式授权播放并立即播放
|
||||||
this.allowPlayMap.set(key, true);
|
this.allowPlayMap.set(key, true);
|
||||||
|
console.log(`开始播放音频 ${key}`);
|
||||||
audio.play();
|
audio.play();
|
||||||
this.currentPlayingKey = key;
|
this.currentPlayingKey = key;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/index"
|
"path": "pages/index"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/audio-test"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/calibration"
|
"path": "pages/calibration"
|
||||||
},
|
},
|
||||||
|
|||||||
51
src/pages/audio-test.vue
Normal file
51
src/pages/audio-test.vue
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<script setup>
|
||||||
|
import { ref, onMounted, onBeforeUnmount } from "vue";
|
||||||
|
import Container from "@/components/Container.vue";
|
||||||
|
import audioManager, { audioFils } from "@/audioManager";
|
||||||
|
|
||||||
|
const loaded = ref({});
|
||||||
|
|
||||||
|
const playAudio = (key) => {
|
||||||
|
audioManager.play(key);
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
const loadedAudioKeys = uni.getStorageSync("loadedAudioKeys") || {};
|
||||||
|
loaded.value = loadedAudioKeys;
|
||||||
|
|
||||||
|
uni.$on("audioLoaded", (key) => {
|
||||||
|
loaded.value[key] = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
uni.$off("audioLoaded");
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Container title="应聘测试">
|
||||||
|
<view class="container">
|
||||||
|
<view v-for="key in Object.keys(audioFils)" :key="key">
|
||||||
|
<text>{{ key }}</text>
|
||||||
|
<text v-if="!loaded[key]">未加载</text>
|
||||||
|
<button v-else hover-class="none" @click="playAudio(key)">播放</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</Container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.container > view {
|
||||||
|
width: calc(100% - 50rpx);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 25rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -52,6 +52,11 @@ const toAboutUsPage = () => {
|
|||||||
url: "/pages/about-us",
|
url: "/pages/about-us",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
const toAudioTestPage = () => {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: "/pages/audio-test",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const showLogout = ref(false);
|
const showLogout = ref(false);
|
||||||
const logout = () => {
|
const logout = () => {
|
||||||
@@ -126,6 +131,11 @@ onMounted(() => {
|
|||||||
<image src="../static/my-grow.png" mode="widthFix" />
|
<image src="../static/my-grow.png" mode="widthFix" />
|
||||||
</view>
|
</view>
|
||||||
<UserItem title="关于我们" :onClick="toAboutUsPage" />
|
<UserItem title="关于我们" :onClick="toAboutUsPage" />
|
||||||
|
<UserItem
|
||||||
|
title="音频测试"
|
||||||
|
:onClick="toAudioTestPage"
|
||||||
|
v-if="showLogout"
|
||||||
|
/>
|
||||||
<UserItem
|
<UserItem
|
||||||
title="退出登录(仅用于测试)"
|
title="退出登录(仅用于测试)"
|
||||||
:onClick="logout"
|
:onClick="logout"
|
||||||
|
|||||||
Reference in New Issue
Block a user