perf: 优化图标展示,修复 dataset 的问题(我TM就不该相信这个半成品),优化性能监听

This commit is contained in:
奔跑的面条
2022-09-11 22:53:00 +08:00
parent 99aea4b9d3
commit 27020b2920
34 changed files with 562 additions and 302 deletions
@@ -6,8 +6,13 @@
</span>
</template>
<span :style="`color:${numberColor};font-size:${numberSize}px`">
<n-number-animation :from="option.from" :to="option.dataset" :duration="dur * 1000" :show-separator="showSeparator"
:precision="precision"></n-number-animation>
<n-number-animation
:from="option.from"
:to="option.dataset"
:duration="dur * 1000"
:show-separator="showSeparator"
:precision="precision"
></n-number-animation>
</span>
<template #suffix>
<span :style="`color:${suffixColor};font-size:${numberSize}px`">
@@ -26,25 +31,16 @@ import { useChartDataFetch } from '@/hooks'
const props = defineProps({
chartConfig: {
type: Object as PropType<CreateComponentType>,
required: true,
},
required: true
}
})
const option = reactive({
from: 0,
dataset: 0,
dataset: 0
})
const { w, h } = toRefs(props.chartConfig.attr)
let {
dur,
showSeparator,
prefixText,
prefixColor,
suffixText,
suffixColor,
precision,
numberSize,
numberColor,
} = toRefs(props.chartConfig.option)
let { dur, showSeparator, prefixText, prefixColor, suffixText, suffixColor, precision, numberSize, numberColor } =
toRefs(props.chartConfig.option)
const updateNumber = (newData: number) => {
// 原来的目标值作为新的数字动画的起始值
@@ -56,14 +52,19 @@ watch(
() => props.chartConfig.option.from,
() => {
option.from = props.chartConfig.option.from
}, { immediate: true }
},
{ immediate: true }
)
watch(
() => props.chartConfig.option.dataset,
() => {
option.dataset = props.chartConfig.option.dataset
}, { immediate: true }
},
{
immediate: true,
deep: false
}
)
useChartDataFetch(props.chartConfig, useChartEditStore, updateNumber)