feat:比赛优化

This commit is contained in:
2026-05-26 11:43:35 +08:00
parent 8664ae9fe4
commit 8ef64f8f42
30 changed files with 4575 additions and 38 deletions

View File

@@ -54,7 +54,7 @@ const onClick = debounce(async () => {
await uni.$checkAudio();
if (result.mode <= 3) {
uni.navigateTo({
url: `/pages/team-battle?battleId=${result.matchId}`,
url: `/pages/team-battle/index?battleId=${result.matchId}`,
});
} else {
uni.navigateTo({

View File

@@ -116,7 +116,7 @@ const backToGame = debounce(async () => {
await checkAudioProgress();
if (result.mode <= 3) {
uni.navigateTo({
url: `/pages/team-battle?battleId=${result.matchId}`,
url: `/pages/team-battle/index?battleId=${result.matchId}`,
});
} else {
uni.navigateTo({

View File

@@ -185,7 +185,13 @@ onBeforeUnmount(() => {
}}</text
>
</view>
<view v-if="currentPage === 'pages/team-battle'" class="battle-progress">
<view
v-if="
currentPage === 'pages/team-battle' ||
currentPage === 'pages/team-battle/index'
"
class="battle-progress"
>
<HeaderProgress />
</view>
<!-- 对战房间:整个胶囊为分享按钮,房号从 Store 读取fixed 定位紧靠系统胶囊左侧 -->

View File

@@ -1,5 +1,5 @@
<script setup>
import { ref, watch, onMounted, computed } from "vue";
import { ref, watch } from "vue";
const props = defineProps({
isRed: {
type: Boolean,
@@ -10,7 +10,7 @@ const props = defineProps({
default: () => [],
},
currentShooterId: {
type: Number,
type: [Number, String],
default: "",
},
});
@@ -30,31 +30,35 @@ const getPos = (id) => {
return sort * 40;
};
onMounted(() => {
props.team.forEach((p, index) => {
players.value[p.id] = { sort: index, ...p };
const syncPlayers = () => {
const nextPlayers = {};
const shooterId = props.currentShooterId;
const shooterIndex = props.team.findIndex(
(p) => String(p?.id) === String(shooterId)
);
const nextTeam = [...props.team];
currentTeam.value = !!shooterId && shooterIndex >= 0;
firstName.value = "";
if (currentTeam.value) {
const target = nextTeam.splice(shooterIndex, 1)[0];
if (target) {
nextTeam.unshift(target);
firstName.value = target.name || "";
}
}
nextTeam.forEach((p, index) => {
if (p?.id) nextPlayers[p.id] = { sort: index, ...p };
});
});
players.value = nextPlayers;
};
watch(
() => props.currentShooterId,
(newVal) => {
if (!newVal) return;
const index = props.team.findIndex((p) => p.id === newVal);
currentTeam.value = index >= 0;
if (index >= 0) {
const newPlayers = [...props.team];
const target = newPlayers.splice(index, 1)[0];
if (target) {
newPlayers.unshift(target);
firstName.value = target.name;
newPlayers.forEach((p, index) => {
players.value[p.id] = { sort: index, ...p };
});
}
}
},
{ immediate: true }
[() => props.team, () => props.currentShooterId],
syncPlayers,
{ immediate: true, deep: true }
);
</script>
@@ -70,7 +74,7 @@ watch(
/>
<view
v-for="(item, index) in team"
:key="index"
:key="item.id || index"
class="player"
:style="{
width: (isFirst(item.id) ? 80 : 60) + 'rpx',