fix: 解决预览请求错误问题

This commit is contained in:
奔跑的面条
2022-07-20 21:30:32 +08:00
parent 997790e653
commit b37c8114d8
2 changed files with 17 additions and 23 deletions
+11 -8
View File
@@ -1,6 +1,6 @@
import { ref, toRefs } from 'vue'
import { ref, toRefs, toRaw } from 'vue'
import type VChart from 'vue-echarts'
import { http } from '@/api/http'
import { customizeHttp } from '@/api/http'
import { CreateComponentType, ChartFrameEnum } from '@/packages/index.d'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { RequestDataTypeEnum } from '@/enums/httpEnum'
@@ -25,22 +25,25 @@ export const useChartDataFetch = (
const requestIntervalFn = () => {
const chartEditStore = useChartEditStore()
// 全局数据
const {
requestOriginUrl,
requestIntervalUnit: globalUnit,
requestInterval: globalRequestInterval
} = toRefs(chartEditStore.getRequestGlobalConfig)
// 组件类型
const { chartFrame } = targetComponent.chartConfig
// 请求配置
// 目标组件
const {
requestDataType,
requestHttpType,
requestUrl,
requestIntervalUnit: targetUnit,
requestInterval: targetInterval
} = toRefs(targetComponent.request)
// 组件类型
const { chartFrame } = targetComponent.chartConfig
// 非请求类型
if (requestDataType.value !== RequestDataTypeEnum.AJAX) return
@@ -55,8 +58,8 @@ export const useChartDataFetch = (
clearInterval(fetchInterval)
const fetchFn = async () => {
const res: any = await http(requestHttpType.value)(completePath || '', {})
if (res.data) {
const res = await customizeHttp(toRaw(targetComponent.request), toRaw(chartEditStore.requestGlobalConfig))
if (res && res.data) {
try {
const filter = targetComponent.filter
// 更新回调函数