fix: 设置图表只在预览页面进行轮询请求

This commit is contained in:
MTrun 2022-03-24 16:51:31 +08:00
parent 66373a427b
commit 19ed2fec19

View File

@ -14,7 +14,7 @@ export const useChartDataFetch = (chartConfig: CreateComponentType) => {
const vChartRef = ref<typeof VChart | null>(null) const vChartRef = ref<typeof VChart | null>(null)
let fetchInterval: any = 0 let fetchInterval: any = 0
watchEffect(() => { isPreview() && watchEffect(() => {
clearInterval(fetchInterval) clearInterval(fetchInterval)
const chartEditStore = useChartEditStore() const chartEditStore = useChartEditStore()
@ -36,9 +36,8 @@ export const useChartDataFetch = (chartConfig: CreateComponentType) => {
const res = await http(requestHttpType.value)(completePath || '', {}) const res = await http(requestHttpType.value)(completePath || '', {})
if (res.data) { if (res.data) {
nextTick(() => { nextTick(() => {
chartConfig.option.dataset = res.data as any if(vChartRef.value) {
if(isPreview() && vChartRef.value) { vChartRef.value.setOption({dataset: res.data})
vChartRef.value.setOption(chartConfig.option)
} }
}) })
} }