perf: 优化过滤器体验,提示错误内容

This commit is contained in:
奔跑的面条 2023-02-09 11:29:23 +08:00
parent d774a52c4f
commit dea849cfdb
2 changed files with 16 additions and 11 deletions

View File

@ -122,23 +122,28 @@ const calcData = (data: any, type?: string) => {
//
const calcCapsuleLengthAndLabelData = (dataset: any) => {
const { source } = dataset
if (!source.length) return
try {
const { source } = dataset
if (!source || !source.length) return
state.capsuleItemHeight = numberSizeHandle(state.mergedConfig.itemHeight)
const capsuleValue = source.map((item: DataProps) => item[state.mergedConfig.dataset.dimensions[1]])
state.capsuleItemHeight = numberSizeHandle(state.mergedConfig.itemHeight)
const capsuleValue = source.map((item: DataProps) => item[state.mergedConfig.dataset.dimensions[1]])
const maxValue = Math.max(...capsuleValue)
const maxValue = Math.max(...capsuleValue)
state.capsuleValue = capsuleValue
state.capsuleValue = capsuleValue
state.capsuleLength = capsuleValue.map((v: any) => (maxValue ? v / maxValue : 0))
state.capsuleLength = capsuleValue.map((v: any) => (maxValue ? v / maxValue : 0))
const oneFifth = maxValue / 5
const oneFifth = maxValue / 5
const labelData = Array.from(new Set(new Array(6).fill(0).map((v, i) => Math.ceil(i * oneFifth))))
const labelData = Array.from(new Set(new Array(6).fill(0).map((v, i) => Math.ceil(i * oneFifth))))
state.labelData = labelData
state.labelData = labelData
} catch (error) {
console.warn(error);
}
}
const numberSizeHandle = (val: string | number) => {

View File

@ -150,7 +150,7 @@ const filterRes = computed(() => {
} catch (error) {
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
errorFlag.value = true
return '过滤函数错误'
return `过滤函数错误,日志:${error}`
}
})