个人12支练习流程修改

This commit is contained in:
kron
2025-11-13 19:57:44 +08:00
parent be0d3a9e3c
commit 66705ae9b1
3 changed files with 34 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
<script setup>
import { ref, watch, onMounted, onBeforeUnmount } from "vue";
import { ref, watch, onMounted, onBeforeUnmount, computed } from "vue";
import audioManager from "@/audioManager";
import { MESSAGETYPES } from "@/constants";
import { getDirectionText } from "@/util";
@@ -48,6 +48,7 @@ const currentRound = ref(props.currentRound);
const currentRoundEnded = ref(false);
const ended = ref(false);
const halfTime = ref(false);
const wait = ref(0);
watch(
() => props.tips,
@@ -108,6 +109,13 @@ watch(
}
);
const tipContent = computed(() => {
if (halfTime.value) {
return props.battleId ? "中场休息" : `中场休息(${wait.value}秒)`;
}
return props.start && remain.value === 0 ? "时间到!" : props.tips;
});
const updateRemain = (value) => {
if (timer.value) clearInterval(timer.value);
remain.value = Math.round(value);
@@ -154,8 +162,21 @@ async function onReceiveMessage(messages = []) {
} else if (msg.constructor === MESSAGETYPES.CurrentRoundEnded) {
currentRoundEnded.value = true;
} else if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
halfTime.value = true;
audioManager.play("中场休息");
if (props.battleId) {
halfTime.value = true;
audioManager.play("中场休息");
return;
}
if (wait.value !== msg.wait) {
wait.value = msg.wait;
if (msg.wait === 20) {
halfTime.value = true;
audioManager.play("中场休息");
}
if (msg.wait === 0) {
halfTime.value = false;
}
}
} else if (msg.constructor === MESSAGETYPES.MatchOver) {
audioManager.play("比赛结束");
} else if (msg.constructor === MESSAGETYPES.FinalShoot) {
@@ -188,7 +209,7 @@ onBeforeUnmount(() => {
<view class="container" :style="{ display: show ? 'block' : 'none' }">
<view>
<image src="../static/shooter.png" mode="widthFix" />
<text>{{ start && remain === 0 ? "时间到!" : tips }}</text>
<text>{{ tipContent }}</text>
<button hover-class="none" @click="updateSound">
<image
:src="`../static/sound${sound ? '' : '-off'}-yellow.png`"

View File

@@ -26,6 +26,7 @@ const practiseResult = ref({});
const practiseId = ref("");
const showGuide = ref(false);
const tips = ref("");
const wait = ref(0);
const onReady = async () => {
const result = await createPractiseAPI(total);
@@ -54,8 +55,7 @@ async function onReceiveMessage(messages = []) {
}, 3000);
}
}
}
if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) {
} else if (msg.constructor === MESSAGETYPES.ShootSyncMePracticeID) {
if (practiseId.value && practiseId.value === msg.practice.id) {
setTimeout(() => {
start.value = false;
@@ -66,6 +66,10 @@ async function onReceiveMessage(messages = []) {
};
}, 1500);
}
} else if (msg.constructor === MESSAGETYPES.HalfTimeOver) {
wait.value = msg.wait;
if (msg.wait === 20) uni.$emit("update-ramain", 0);
if (msg.wait === 0) uni.$emit("update-ramain", 60);
}
});
}
@@ -122,6 +126,7 @@ onBeforeUnmount(() => {
}轮`
}`"
:start="start"
:total="60"
/>
<view class="user-row">
<Avatar :src="user.avatar" :size="35" />
@@ -135,6 +140,7 @@ onBeforeUnmount(() => {
:totalRound="start ? total / 4 : 0"
:currentRound="currentRound"
:scores="scores"
:stop="wait > 0"
/>
<ScorePanel2 :scores="scores.map((s) => s.ring)" />
<ScoreResult

View File

@@ -105,11 +105,7 @@ onBeforeUnmount(() => {
<view>
<TestDistance v-if="!practiseId" />
<block v-if="practiseId">
<ShootProgress
:start="start"
:tips="`请连续射${total}支箭`"
:total="120"
/>
<ShootProgress :start="start" :tips="`请连续射${total}支箭`" />
<view class="user-row">
<Avatar :src="user.avatar" :size="35" />
<BubbleTip v-if="showGuide" type="normal2">