细节调整

This commit is contained in:
kron
2025-11-13 14:51:44 +08:00
parent 24996a4b35
commit eba65a4fbd

View File

@@ -1,15 +1,11 @@
<script setup> <script setup>
import { ref, computed } from "vue"; import { ref, computed, onMounted } from "vue";
const props = defineProps({ const props = defineProps({
data: { data: {
type: Object, type: Object,
default: () => ({}), default: () => ({}),
}, },
total: {
type: Number,
default: 0,
},
}); });
const barColor = (rate) => { const barColor = (rate) => {
@@ -44,13 +40,12 @@ const ringText = (ring) => {
<view> <view>
<view v-for="(b, index) in bars" :key="index"> <view v-for="(b, index) in bars" :key="index">
<text v-if="b && b.rate"> <text v-if="b && b.rate">
{{ total === 0 ? `${Number((b.rate * 100).toFixed(1))}%` : b.rate }} {{ `${Number((b.rate * 100).toFixed(1))}%` }}
</text> </text>
<view <view
:style="{ :style="{
background: barColor(total === 0 ? b.rate : b.rate / total), background: barColor(b.rate),
height: height: (b.rate === 1 ? 150 : b.rate * 240) + 'rpx',
Math.max((total === 0 ? b.rate : b.rate / total) * 240) + 'rpx',
}" }"
> >
</view> </view>