计分本修改

This commit is contained in:
kron
2025-10-11 09:06:56 +08:00
parent fb0cf62ca0
commit 5bf3bbccdb
6 changed files with 155 additions and 30 deletions

View File

@@ -19,6 +19,10 @@ const props = defineProps({
type: Function,
default: null,
},
editMode: {
type: Boolean,
default: true,
},
});
const rect = ref({});
@@ -150,6 +154,7 @@ onMounted(async () => {
<template>
<view
:style="{ overflowY: editMode ? 'auto' : 'hidden' }"
class="container"
@tap="onClick"
@touchmove="onDrag"
@@ -231,7 +236,6 @@ onMounted(async () => {
width: 100vw;
height: 100vw;
overflow-x: hidden;
overflow-y: auto;
}
.container::-webkit-scrollbar {
width: 0;

View File

@@ -273,6 +273,6 @@ onBeforeUnmount(() => {
font-size: 30rpx;
color: #333333;
margin: 0 20rpx;
max-width: 280rpx;
max-width: 300rpx;
}
</style>

View File

@@ -6,6 +6,10 @@ const props = defineProps({
type: Object,
default: () => ({}),
},
total: {
type: Number,
default: 0,
},
});
const barColor = (rate) => {
@@ -15,20 +19,16 @@ const barColor = (rate) => {
};
const bars = computed(() => {
let data = Object.values(props.data);
if (!data.length) data = new Array(11).fill({ ring: 0, rate: 0 });
const newList = data.map((item, index) => {
const newList = new Array(12).fill({ ring: 0, rate: 0 }).map((_, index) => {
let ring = index;
if (ring === 11) ring = "M";
if (ring === 0) ring = "X";
return {
ring: ring,
rate: item,
rate: props.data[index] || 0,
};
});
if (newList.length >= 12) {
[newList[0], newList[11]] = [newList[11], newList[0]];
}
[newList[0], newList[11]] = [newList[11], newList[0]];
return newList.reverse();
});
@@ -44,12 +44,12 @@ const ringText = (ring) => {
<view>
<view v-for="(b, index) in bars" :key="index">
<text v-if="b && b.rate">
{{ Number((b.rate * 100).toFixed(1)) }}%
{{ total === 0 ? `${Number((b.rate * 100).toFixed(1))}%` : b.rate }}
</text>
<view
:style="{
background: barColor(b.rate),
height: b.rate * 300 + 'rpx',
background: barColor(total === 0 ? b.rate : b.rate / total),
height: (total === 0 ? b.rate : b.rate / total) * 300 + 'rpx',
}"
>
</view>
@@ -64,6 +64,12 @@ const ringText = (ring) => {
</template>
<style scoped>
.container {
min-height: 150rpx;
display: flex;
flex-direction: column;
justify-content: flex-end;
}
.container > view {
padding: 0 10rpx;
}
@@ -79,10 +85,11 @@ const ringText = (ring) => {
align-items: center;
font-size: 18rpx;
color: #333;
width: 5vw;
}
.container > view:first-child > view > view {
width: 100%;
transition: all 0.3s ease;
width: 5vw;
height: 0;
}
.container > view:last-child {