diff --git a/src/audioManager.js b/src/audioManager.js index 0d5fc18..9e56ed5 100644 --- a/src/audioManager.js +++ b/src/audioManager.js @@ -1,4 +1,5 @@ export const audioFils = { + 点击按钮: "https://static.shelingxingqiu.com/shootmini/static/audio/%E7%82%B9%E5%87%BB%E6%8C%89%E9%92%AE.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", // 激光已校准: diff --git a/src/components/AppFooter.vue b/src/components/AppFooter.vue index 3a44260..05f2ebe 100644 --- a/src/components/AppFooter.vue +++ b/src/components/AppFooter.vue @@ -31,7 +31,7 @@ function handleTabClick(index) { v-for="(tab, index) in tabs" :key="index" class="tab-item" - @click="handleTabClick(index)" + @click="$clickSound(() => handleTabClick(index))" :style="{ width: index === 1 ? '36%' : '20%', }" diff --git a/src/components/Container.vue b/src/components/Container.vue index 109606a..280959c 100644 --- a/src/components/Container.vue +++ b/src/components/Container.vue @@ -206,7 +206,7 @@ const goCalibration = async () => { - + diff --git a/src/components/CreateRoom.vue b/src/components/CreateRoom.vue index 0b32a26..e66dd22 100644 --- a/src/components/CreateRoom.vue +++ b/src/components/CreateRoom.vue @@ -112,7 +112,7 @@ const createRoom = debounce(async () => { 40厘米全环靶 - 创建房间 + 创建房间 diff --git a/src/components/Matching.vue b/src/components/Matching.vue index c6c109a..f680c0f 100644 --- a/src/components/Matching.vue +++ b/src/components/Matching.vue @@ -123,7 +123,7 @@ onBeforeUnmount(() => { - + diff --git a/src/main.js b/src/main.js index 0a0dccb..8462e70 100644 --- a/src/main.js +++ b/src/main.js @@ -2,12 +2,25 @@ import { createSSRApp } from 'vue' import { createPinia } from 'pinia' import piniaPluginPersistedstate from 'pinia-plugin-persistedstate' import App from './App.vue' +import audioManager from './audioManager' export function createApp() { const app = createSSRApp(App) const pinia = createPinia() pinia.use(piniaPluginPersistedstate) app.use(pinia) + + /** + * 全局点击音效工具函数,用于在任意按钮/元素点击时自动播放音效。 + * 用法:@click="$clickSound(handler)" 或 @click="$clickSound(() => doSomething())" + * @param {Function} handler - 原始点击回调函数(可选,点击时直接调用) + * @param {string} [soundKey='点击按钮'] - audioManager 中的音效 key + */ + app.config.globalProperties.$clickSound = (handler, soundKey = '点击按钮') => { + audioManager.play(soundKey); + if (typeof handler === 'function') handler(); + }; + return { app } diff --git a/src/pages/battle-room.vue b/src/pages/battle-room.vue index 1bf2695..bf27084 100644 --- a/src/pages/battle-room.vue +++ b/src/pages/battle-room.vue @@ -443,7 +443,7 @@ onBeforeUnmount(() => { - + {{ allReady.value ? "即将进入对局..." diff --git a/src/pages/friend-battle.vue b/src/pages/friend-battle.vue index 62e2fd7..2cbdda1 100644 --- a/src/pages/friend-battle.vue +++ b/src/pages/friend-battle.vue @@ -141,7 +141,7 @@ onLoad(async (options) => { - 进入房间 + 进入房间 @@ -155,7 +155,7 @@ onLoad(async (options) => { - + 创建约战房 diff --git a/src/pages/index.vue b/src/pages/index.vue index c3c42ce..bedd679 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -179,7 +179,7 @@ onShareTimeline(() => { v-else src="https://static.shelingxingqiu.com/attachment/2026-01-04/dffohwtk1gwh0xfa6h.png" mode="widthFix" - @click="() => toPage('/pages/my-device')" + @click="$clickSound(() => toPage('/pages/my-device'))" /> 绑定我的智能弓 @@ -197,10 +197,10 @@ onShareTimeline(() => { - + - + @@ -212,7 +212,7 @@ onShareTimeline(() => { /> diff --git a/src/pages/my-device.vue b/src/pages/my-device.vue index 8ca7210..f584210 100644 --- a/src/pages/my-device.vue +++ b/src/pages/my-device.vue @@ -130,7 +130,7 @@ onShow(() => { diff --git a/src/pages/point-book-edit.vue b/src/pages/point-book-edit.vue index 07a42ff..69f61aa 100644 --- a/src/pages/point-book-edit.vue +++ b/src/pages/point-book-edit.vue @@ -198,7 +198,7 @@ onLoad((options) => { diff --git a/src/pages/point-book.vue b/src/pages/point-book.vue index 7494f48..6722cb7 100644 --- a/src/pages/point-book.vue +++ b/src/pages/point-book.vue @@ -329,10 +329,10 @@ onShareTimeline(() => { - - diff --git a/src/pages/ranking.vue b/src/pages/ranking.vue index f5ec941..6b275b6 100644 --- a/src/pages/ranking.vue +++ b/src/pages/ranking.vue @@ -281,27 +281,27 @@ onShow(async () => {