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