fix: 打包时优化代码

This commit is contained in:
huanghao1412 2024-01-25 17:54:32 +08:00
parent c615c38eb9
commit 0de080e710
3 changed files with 14 additions and 12 deletions

View File

@ -3,7 +3,7 @@ import { setOption } from "@/packages/public";
import { ref, toRefs, watch } from "vue";
import { CreateComponentType, ChartFrameEnum } from '@/packages/index.d'
import { useChartEditStore } from "@/store/modules/chartEditStore/chartEditStore";
import { CurrentSourceEnum } from '@/store/modules/chartEditStore/chartEditStore.d'
import { CurrentSourceEnum, resultType } from '@/store/modules/chartEditStore/chartEditStore.d'
import { intervalUnitHandle, newFunctionHandle, isPreview } from "@/utils";
import { cloneDeep } from 'lodash'
import { handlePointHistory } from './commonDataComponents/usePointHistoryRes'
@ -61,13 +61,12 @@ export const useChartCommonData = (
}
}
else if(SingleDataArr.some(_ => _ === currentSource)) { // 单个值的处理
if(targetComponent.commonData[currentSource]?.result) {
stopWatch = true
targetComponent.commonData[currentSource].result = dataset
setTimeout(() => {
stopWatch = false
}, 500)
}
const targetObj = targetComponent.commonData[currentSource] as { result: resultType }
stopWatch = true
targetObj.result = dataset
setTimeout(() => {
stopWatch = false
}, 500)
}
}
}

View File

@ -134,6 +134,7 @@ const props = defineProps({
})
const config = computed(() => {
return props.optionData
})
// 使 TypeScript title
return props.optionData as GlobalThemeJsonType & { title: NonNullable<GlobalThemeJsonType['title']> };
});
</script>

View File

@ -14,6 +14,8 @@ import config, { includes } from './config'
import { useChartCommonData, useChartDataFetch } from '@/hooks'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent, TitleComponent } from 'echarts/components'
import { resultType } from '@/store/modules/chartEditStore/chartEditStore.d'
const props = defineProps({
themeSetting: {
@ -89,7 +91,7 @@ watch(
() => props.chartConfig.commonData,
newData => {
try {
const data = newData[newData.currentSource]
const data = newData[newData.currentSource] as Object & { result: resultType }
dataHandle(data.result)
} catch (error) {
console.log(error)
@ -102,7 +104,7 @@ watch(
)
watch(() => props.chartConfig.option.titleContrl, (v) => {
const commonData = props.chartConfig.commonData
const data = commonData[commonData.currentSource]
const data = commonData[commonData.currentSource] as Object & { result: resultType }
dataHandle(data.result)
}, {
immediate: true,