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

131 lines
2.7 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-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-05-16 15:56:54 +08:00
});
2025-06-09 12:24:01 +08:00
const bgColors = ["#364469", "#692735", "#934B4B", "#A98B69", "#8268A2 "];
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-09 12:24:01 +08:00
<view v-if="!blueTeam.length" class="players-melee">
<view
v-for="(player, index) in players"
:key="index"
:style="{ backgroundColor: bgColors[index] }"
>
<Avatar :src="player.avatar" :size="40" />
<text class="player-name">{{ player.name }}</text>
</view>
2025-05-16 15:56:54 +08:00
</view>
2025-06-09 12:24:01 +08:00
<view v-if="blueTeam.length" class="players">
2025-05-16 15:56:54 +08:00
<view>
2025-06-08 20:59:41 +08:00
<block v-if="blueTeam[0]">
<Avatar :src="blueTeam[0].avatar" frame />
2025-06-09 12:24:01 +08:00
<text class="player-name">{{ blueTeam[0].name }}</text>
2025-06-08 20:59:41 +08:00
<image
v-if="blueTeam[0].winner"
src="../static/winner-badge.png"
mode="widthFix"
/>
</block>
2025-05-16 15:56:54 +08:00
</view>
<view>
2025-06-08 20:59:41 +08:00
<block v-if="redTeam[0]">
<Avatar v-if="redTeam[0]" :src="redTeam[0].avatar" frame />
<text>{{ redTeam[0].name }}</text>
<image
v-if="redTeam[0].winner"
src="../static/winner-badge.png"
mode="widthFix"
/>
</block>
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;
font-size: 14px;
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%;
background-color: #364469;
margin-top: 15px;
}
.players-melee > view {
width: 20%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #fff9;
font-size: 14px;
padding-top: 5px;
}
.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>