Merge branch 'new-race-mode' into test
This commit is contained in:
@@ -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",
|
||||
// 激光已校准:
|
||||
|
||||
@@ -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%',
|
||||
}"
|
||||
|
||||
@@ -206,7 +206,7 @@ const goCalibration = async () => {
|
||||
<button hover-class="none" @click="() => (showHint = false)">
|
||||
取消
|
||||
</button>
|
||||
<button hover-class="none" @click="cancelMatching">确认</button>
|
||||
<button hover-class="none" @click="$clickSound(cancelMatching)">确认</button>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="hintType === 4" class="tip-content">
|
||||
|
||||
@@ -112,7 +112,7 @@ const createRoom = debounce(async () => {
|
||||
<text>40厘米全环靶</text>
|
||||
</view>
|
||||
</view>
|
||||
<SButton :onClick="createRoom">创建房间</SButton>
|
||||
<SButton :onClick="() => $clickSound(createRoom)">创建房间</SButton>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ onBeforeUnmount(() => {
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<button hover-class="none" @click="stopMatch">取消匹配</button>
|
||||
<button hover-class="none" @click="$clickSound(stopMatch)">取消匹配</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
13
src/main.js
13
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
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ onBeforeUnmount(() => {
|
||||
<PlayerSeats v-if="room.battleType === 2" :total="room.count || 10" :players="players"
|
||||
:removePlayer="removePlayer" :isOwner="owner.id === user.id" />
|
||||
<view>
|
||||
<SButton :disabled="!canClick" :onClick="getReady">
|
||||
<SButton :disabled="!canClick" :onClick="() => $clickSound(getReady)">
|
||||
{{
|
||||
allReady.value
|
||||
? "即将进入对局..."
|
||||
|
||||
@@ -141,7 +141,7 @@ onLoad(async (options) => {
|
||||
<image src="../static/founded-room.png" mode="widthFix" />
|
||||
<view>
|
||||
<input placeholder="输入房间号" v-model="roomNumber" placeholder-style="color: #ccc" />
|
||||
<view @click="enterRoom(roomNumber)">进入房间</view>
|
||||
<view @click="$clickSound(() => enterRoom(roomNumber))">进入房间</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="create-room">
|
||||
@@ -155,7 +155,7 @@ onLoad(async (options) => {
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<SButton width="80%" :rounded="30" :onClick="onCreateRoom">
|
||||
<SButton width="80%" :rounded="30" :onClick="() => $clickSound(onCreateRoom)">
|
||||
创建约战房
|
||||
</SButton>
|
||||
</view>
|
||||
|
||||
@@ -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'))"
|
||||
/>
|
||||
<block v-if="user.id">
|
||||
<text v-if="!device.deviceId">绑定我的智能弓</text>
|
||||
@@ -197,10 +197,10 @@ onShareTimeline(() => {
|
||||
</BubbleTip>
|
||||
</view>
|
||||
<view class="play-card">
|
||||
<view @click="() => toPage('/pages/practise')">
|
||||
<view @click="$clickSound(() => toPage('/pages/practise'))">
|
||||
<image src="../static/my-practise.png" mode="widthFix"/>
|
||||
</view>
|
||||
<view @click="() => toPage('/pages/friend-battle')">
|
||||
<view @click="$clickSound(() => toPage('/pages/friend-battle'))">
|
||||
<image src="../static/friend-battle.png" mode="widthFix"/>
|
||||
</view>
|
||||
</view>
|
||||
@@ -212,7 +212,7 @@ onShareTimeline(() => {
|
||||
/>
|
||||
<button
|
||||
class="into-btn"
|
||||
@click="() => toPage('/pages/ranking')"
|
||||
@click="$clickSound(() => toPage('/pages/ranking'))"
|
||||
hover-class="none"
|
||||
></button>
|
||||
<view class="ranking-players" @click="toRankListPage">
|
||||
|
||||
@@ -130,7 +130,7 @@ onShow(() => {
|
||||
<template>
|
||||
<Container title="弓箭绑定">
|
||||
<view v-if="!device.deviceId" class="scan-code">
|
||||
<button hover-class="none" @click="handleScan">
|
||||
<button hover-class="none" @click="$clickSound(handleScan)">
|
||||
<image src="../static/scan.png" mode="widthFix" />
|
||||
</button>
|
||||
<button hover-class="none" @click="showTip = true">
|
||||
@@ -269,7 +269,7 @@ onShow(() => {
|
||||
</view>
|
||||
</view>
|
||||
<view :style="{ marginTop: '240rpx' }">
|
||||
<SButton :onClick="unbindDevice" width="80vw" :rounded="40"
|
||||
<SButton :onClick="() => $clickSound(unbindDevice)" width="80vw" :rounded="40"
|
||||
>解绑</SButton
|
||||
>
|
||||
</view>
|
||||
|
||||
@@ -114,7 +114,7 @@ onMounted(async () => {
|
||||
/>
|
||||
</view>
|
||||
<template #bottom>
|
||||
<SButton :rounded="50" :onClick="toEditPage">下一步</SButton>
|
||||
<SButton :rounded="50" :onClick="() => $clickSound(toEditPage)">下一步</SButton>
|
||||
</template>
|
||||
</Container>
|
||||
</template>
|
||||
|
||||
@@ -198,7 +198,7 @@ onLoad((options) => {
|
||||
</ScreenHint2>
|
||||
</view>
|
||||
<template #bottom>
|
||||
<SButton :rounded="50" :onClick="onSubmit">
|
||||
<SButton :rounded="50" :onClick="() => $clickSound(onSubmit)">
|
||||
{{ currentGroup === groups ? "保存并查看分析" : "下一组" }}
|
||||
</SButton>
|
||||
</template>
|
||||
|
||||
@@ -329,10 +329,10 @@ onShareTimeline(() => {
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<button hover-class="none" @click="toRecordPage" class="image-btn">
|
||||
<button hover-class="none" @click="$clickSound(toRecordPage)" class="image-btn">
|
||||
<image src="../static/record-btn.png" mode="widthFix" />
|
||||
</button>
|
||||
<button hover-class="none" @click="startScoring" class="image-btn">
|
||||
<button hover-class="none" @click="$clickSound(startScoring)" class="image-btn">
|
||||
<image src="../static/start-scoring.png" mode="widthFix" />
|
||||
</button>
|
||||
</view>
|
||||
|
||||
@@ -281,27 +281,27 @@ onShow(async () => {
|
||||
<image
|
||||
src="../static/rank/battle1v1.svg"
|
||||
mode="widthFix"
|
||||
@click.stop="() => toMatchPage(1, 2)"
|
||||
@click.stop="$clickSound(() => toMatchPage(1, 2))"
|
||||
/>
|
||||
<image
|
||||
src="../static/rank/battle2v2.svg"
|
||||
mode="widthFix"
|
||||
@click.stop="() => toMatchPage(2, 4)"
|
||||
@click.stop="$clickSound(() => toMatchPage(2, 4))"
|
||||
/>
|
||||
<image
|
||||
src="../static/rank/battle3v3.svg"
|
||||
mode="widthFix"
|
||||
@click.stop="() => toMatchPage(3, 6)"
|
||||
@click.stop="$clickSound(() => toMatchPage(3, 6))"
|
||||
/>
|
||||
<image
|
||||
src="../static/rank/battle5.svg"
|
||||
mode="widthFix"
|
||||
@click.stop="() => toMatchPage(4, 5)"
|
||||
@click.stop="$clickSound(() => toMatchPage(4, 5))"
|
||||
/>
|
||||
<image
|
||||
src="../static/rank/battle10.svg"
|
||||
mode="widthFix"
|
||||
@click.stop="() => toMatchPage(5, 10)"
|
||||
@click.stop="$clickSound(() => toMatchPage(5, 10))"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user