Files
shoot-miniprograms/src/components/BattleHeader.vue

146 lines
2.9 KiB
Vue
Raw Normal View History

2025-05-16 15:56:54 +08:00
<script setup>
2025-06-05 21:32:51 +08:00
import Avatar from "@/components/Avatar.vue";
2025-06-28 12:38:38 +08:00
import { meleeAvatarColors } from "@/constants";
2025-05-16 15:56:54 +08:00
defineProps({
2025-06-09 12:24:01 +08:00
players: {
type: Array,
default: () => [],
2025-05-16 15:56:54 +08:00
},
2025-06-05 21:32:51 +08:00
blueTeam: {
type: Array,
default: () => [],
},
redTeam: {
type: Array,
default: () => [],
},
2025-06-18 02:02:09 +08:00
showRank: {
type: Boolean,
default: false,
},
winner: {
type: Number,
2025-06-19 21:03:33 +08:00
default: 2,
2025-06-18 02:02:09 +08:00
},
2025-05-16 15:56:54 +08:00
});
</script>
<template>
<view class="container">
<image
2025-06-09 12:24:01 +08:00
:src="`../static/battle-header${blueTeam.length ? '' : '-melee'}.png`"
2025-05-16 15:56:54 +08:00
mode="widthFix"
/>
2025-06-13 14:05:30 +08:00
<view v-if="players.length" class="players-melee">
2025-06-09 12:24:01 +08:00
<view
v-for="(player, index) in players"
:key="index"
2025-06-28 12:38:38 +08:00
:style="{
backgroundColor: meleeAvatarColors[index],
width: `${Math.max(100 / players.length, 18)}vw`,
}"
2025-06-09 12:24:01 +08:00
>
2025-06-18 02:02:09 +08:00
<Avatar
:src="player.avatar"
:size="40"
:rank="showRank ? index + 1 : 0"
/>
2025-06-09 12:24:01 +08:00
<text class="player-name">{{ player.name }}</text>
</view>
2025-05-16 15:56:54 +08:00
</view>
2025-06-13 14:05:30 +08:00
<view v-if="blueTeam.length && redTeam.length" class="players">
2025-05-16 15:56:54 +08:00
<view>
2025-07-14 15:13:10 +08:00
<Avatar :src="blueTeam[0].avatar" :rankLvl="blueTeam[0].rankLvl" />
2025-06-13 14:05:30 +08:00
<text class="player-name">{{ blueTeam[0].name }}</text>
<image
2025-06-18 02:02:09 +08:00
v-if="winner === 1"
2025-06-13 14:05:30 +08:00
src="../static/winner-badge.png"
mode="widthFix"
/>
2025-05-16 15:56:54 +08:00
</view>
<view>
2025-07-07 19:01:14 +08:00
<Avatar
v-if="redTeam[0]"
:src="redTeam[0].avatar"
2025-07-14 15:13:10 +08:00
:rankLvl="redTeam[0].rankLvl"
2025-07-07 19:01:14 +08:00
/>
2025-06-13 14:05:30 +08:00
<text class="player-name">{{ redTeam[0].name }}</text>
<image
2025-06-18 02:02:09 +08:00
v-if="winner === 0"
2025-06-13 14:05:30 +08:00
src="../static/winner-badge.png"
mode="widthFix"
/>
2025-05-16 15:56:54 +08:00
</view>
</view>
</view>
</template>
<style scoped>
.container {
width: 100%;
position: relative;
margin-bottom: 10px;
2025-06-09 12:24:01 +08:00
padding-top: 5px;
2025-05-16 15:56:54 +08:00
}
.container > image:first-child {
position: absolute;
width: 100%;
2025-06-08 12:52:49 +08:00
top: -5px;
z-index: 1;
2025-05-16 15:56:54 +08:00
}
.players {
display: flex;
}
.players > view {
width: 50%;
2025-06-09 12:24:01 +08:00
height: 85px;
2025-05-16 15:56:54 +08:00
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #fff9;
2025-06-18 21:30:54 +08:00
font-size: 12px;
2025-06-09 12:24:01 +08:00
margin-top: 15px;
2025-06-05 21:32:51 +08:00
overflow: hidden;
2025-06-08 12:52:49 +08:00
position: relative;
2025-06-09 12:24:01 +08:00
padding-top: 5px;
2025-05-16 15:56:54 +08:00
}
.players > view:first-child {
background-color: #364469;
}
.players > view:last-child {
background-color: #692735;
}
2025-06-08 12:52:49 +08:00
.players > view > image:last-child {
position: absolute;
width: 60px;
right: 0;
bottom: 0;
}
2025-06-09 12:24:01 +08:00
.players-melee {
display: flex;
height: 85px;
width: 100%;
margin-top: 15px;
2025-06-28 12:38:38 +08:00
overflow-x: auto;
2025-06-09 12:24:01 +08:00
}
.players-melee > view {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #fff9;
2025-06-18 21:30:54 +08:00
font-size: 12px;
2025-06-09 12:24:01 +08:00
padding-top: 5px;
2025-06-28 12:38:38 +08:00
flex: 0 0 auto;
2025-06-09 12:24:01 +08:00
}
.player-name {
margin-top: 5px;
width: 80%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
text-align: center;
}
2025-05-16 15:56:54 +08:00
</style>