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

View File

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

View File

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