diff --git a/src/hooks/useChartDataFetch.hook.ts b/src/hooks/useChartDataFetch.hook.ts index 85c771b3..362cbce0 100644 --- a/src/hooks/useChartDataFetch.hook.ts +++ b/src/hooks/useChartDataFetch.hook.ts @@ -9,7 +9,6 @@ import { isPreview, newFunctionHandle } from '@/utils' // 获取类型 type ChartEditStoreType = typeof useChartEditStore - /** * setdata 数据监听与更改 * @param targetComponent @@ -30,7 +29,12 @@ export const useChartDataFetch = ( // 组件类型 const { chartFrame } = targetComponent.chartConfig // 请求配置 - const { requestDataType, requestHttpType, requestUrl } = toRefs(targetComponent.request) + const { + requestDataType, + requestHttpType, + requestUrl, + requestInterval: targetInterval + } = toRefs(targetComponent.request) // 非请求类型 if (requestDataType.value !== RequestDataTypeEnum.AJAX) return // 处理地址 @@ -65,12 +69,13 @@ export const useChartDataFetch = ( // 立即调用 fetchFn() + // 开启定时 - fetchInterval = setInterval(fetchFn, requestInterval.value * 1000) + const time = targetInterval && targetInterval.value ? targetInterval.value : requestInterval.value + fetchInterval = setInterval(fetchFn, time * 1000) } } isPreview() && requestIntervalFn() - return { vChartRef } } diff --git a/src/packages/public/publicConfig.ts b/src/packages/public/publicConfig.ts index 228f2b6b..d4fde6be 100644 --- a/src/packages/public/publicConfig.ts +++ b/src/packages/public/publicConfig.ts @@ -8,7 +8,7 @@ const requestConfig: RequestConfigType = { requestDataType: RequestDataTypeEnum.STATIC, requestHttpType: RequestHttpEnum.GET, requestUrl: '', - requestInterval: 0 + requestInterval: undefined } export class publicConfig implements PublicConfigType { diff --git a/src/store/modules/chartEditStore/chartEditStore.d.ts b/src/store/modules/chartEditStore/chartEditStore.d.ts index d037e3f2..dab3a992 100644 --- a/src/store/modules/chartEditStore/chartEditStore.d.ts +++ b/src/store/modules/chartEditStore/chartEditStore.d.ts @@ -147,7 +147,7 @@ export type RequestConfigType = { // 源后续的 url requestUrl?: string // 组件定制轮询时间 - requestInterval: number + requestInterval?: number } // Store 类型 diff --git a/src/views/chart/ContentConfigurations/components/CanvasPage/components/ChartDataSetting/index.vue b/src/views/chart/ContentConfigurations/components/CanvasPage/components/ChartDataSetting/index.vue index 7e4ec809..298a14ae 100644 --- a/src/views/chart/ContentConfigurations/components/CanvasPage/components/ChartDataSetting/index.vue +++ b/src/views/chart/ContentConfigurations/components/CanvasPage/components/ChartDataSetting/index.vue @@ -6,12 +6,12 @@ placeholder="源地址如: http://127.0.0.1" > - +