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

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