优化:订单薄最大值逻辑更新

This commit is contained in:
ivan 2026-03-15 21:04:56 +08:00
parent 3983105628
commit a29dac0146

View File

@ -37,7 +37,7 @@
<div v-for="(ask, index) in asksWithCumulativeTotal" :key="index" class="order-item">
<div class="order-progress">
<HorizontalProgressBar
:max="maxAsksTotal"
:max="maxOrderBookTotal"
:value="ask.total"
:fillStyle="{ backgroundColor: '#e89595' }"
:trackStyle="{ backgroundColor: 'transparent' }"
@ -57,7 +57,7 @@
>
<div class="order-progress">
<HorizontalProgressBar
:max="maxBidsTotal"
:max="maxOrderBookTotal"
:value="bid.total"
:fillStyle="{ backgroundColor: '#7acc7a' }"
:trackStyle="{ backgroundColor: 'transparent' }"
@ -284,17 +284,12 @@ const bidsWithCumulativeTotal = computed(() => {
// Reverse to display in descending order
})
// Calculate max total from cumulative totals
const maxAsksTotal = computed(() => {
// Shared max total from both asks and bids cumulative totals (for progress bar scale)
const maxOrderBookTotal = computed(() => {
const askTotals = asksWithCumulativeTotal.value.map((item) => item.cumulativeTotal)
const allTotals = [...askTotals]
return Math.max(...allTotals)
})
const maxBidsTotal = computed(() => {
const bidTotals = bidsWithCumulativeTotal.value.map((item) => item.cumulativeTotal)
const allTotals = [...bidTotals]
return Math.max(...allTotals)
const allTotals = [...askTotals, ...bidTotals]
return allTotals.length ? Math.max(...allTotals) : 0
})
</script>