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

81 lines
1.5 KiB
Vue
Raw Normal View History

2025-05-10 16:57:36 +08:00
<script setup>
2025-06-15 15:53:57 +08:00
import { ref, watch } from "vue";
2025-05-10 16:57:36 +08:00
const props = defineProps({
rowCount: {
type: Number,
default: 0,
},
total: {
type: Number,
default: 0,
},
scores: {
type: Array,
default: () => [],
},
2025-06-16 00:44:28 +08:00
margin: {
type: Number,
default: 4,
},
fontSize: {
type: Number,
default: 25,
},
2025-05-10 16:57:36 +08:00
});
const items = ref(new Array(props.total).fill(9));
2025-06-15 15:53:57 +08:00
watch(
() => props.total,
(newValue) => {
items.value = new Array(newValue).fill(9);
}
);
2025-05-10 16:57:36 +08:00
</script>
<template>
<view class="container">
<view
v-for="(_, index) in items"
:key="index"
class="score-item"
2025-06-16 00:44:28 +08:00
:style="{
width: 100 / (rowCount + 2) + 'vw',
height: 100 / (rowCount + 2) + 'vw',
2025-06-16 22:43:39 +08:00
lineHeight: 100 / (rowCount + 2) + 'vw',
2025-06-16 00:44:28 +08:00
fontSize: fontSize + 'px',
margin: margin + 'px',
}"
2025-05-10 16:57:36 +08:00
>
2025-06-24 13:18:03 +08:00
<image src="../static/score-bg.png" mode="widthFix" />
<text>{{ scores[index] }}</text>
2025-05-10 16:57:36 +08:00
</view>
</view>
</template>
<style scoped>
.container {
width: 90vw;
display: flex;
flex-wrap: wrap;
2025-06-16 00:44:28 +08:00
justify-content: center;
2025-05-10 16:57:36 +08:00
margin: 0 5vw;
}
.score-item {
2025-06-24 13:18:03 +08:00
/* background-image: url("../static/score-bg.png");
2025-05-10 16:57:36 +08:00
background-size: cover;
background-repeat: no-repeat;
2025-06-24 13:18:03 +08:00
background-position: center; */
2025-05-10 16:57:36 +08:00
color: #fed847;
display: flex;
justify-content: center;
align-items: center;
2025-06-24 13:18:03 +08:00
position: relative;
}
.score-item > image {
position: absolute;
width: 100%;
top: 5%;
}
.score-item > text {
position: relative;
2025-05-10 16:57:36 +08:00
}
</style>