fix: 解决预览请求错误问题
This commit is contained in:
parent
072918fc6f
commit
c05f851e02
@ -1,6 +1,6 @@
|
|||||||
import { ref, toRefs } from 'vue'
|
import { ref, toRefs, toRaw } from 'vue'
|
||||||
import type VChart from 'vue-echarts'
|
import type VChart from 'vue-echarts'
|
||||||
import { http } from '@/api/http'
|
import { customizeHttp } from '@/api/http'
|
||||||
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 { RequestDataTypeEnum } from '@/enums/httpEnum'
|
import { RequestDataTypeEnum } from '@/enums/httpEnum'
|
||||||
@ -25,22 +25,25 @@ export const useChartDataFetch = (
|
|||||||
|
|
||||||
const requestIntervalFn = () => {
|
const requestIntervalFn = () => {
|
||||||
const chartEditStore = useChartEditStore()
|
const chartEditStore = useChartEditStore()
|
||||||
|
|
||||||
|
// 全局数据
|
||||||
const {
|
const {
|
||||||
requestOriginUrl,
|
requestOriginUrl,
|
||||||
requestIntervalUnit: globalUnit,
|
requestIntervalUnit: globalUnit,
|
||||||
requestInterval: globalRequestInterval
|
requestInterval: globalRequestInterval
|
||||||
} = toRefs(chartEditStore.getRequestGlobalConfig)
|
} = toRefs(chartEditStore.getRequestGlobalConfig)
|
||||||
// 组件类型
|
|
||||||
const { chartFrame } = targetComponent.chartConfig
|
// 目标组件
|
||||||
// 请求配置
|
|
||||||
const {
|
const {
|
||||||
requestDataType,
|
requestDataType,
|
||||||
requestHttpType,
|
|
||||||
requestUrl,
|
requestUrl,
|
||||||
requestIntervalUnit: targetUnit,
|
requestIntervalUnit: targetUnit,
|
||||||
requestInterval: targetInterval
|
requestInterval: targetInterval
|
||||||
} = toRefs(targetComponent.request)
|
} = toRefs(targetComponent.request)
|
||||||
|
|
||||||
|
// 组件类型
|
||||||
|
const { chartFrame } = targetComponent.chartConfig
|
||||||
|
|
||||||
// 非请求类型
|
// 非请求类型
|
||||||
if (requestDataType.value !== RequestDataTypeEnum.AJAX) return
|
if (requestDataType.value !== RequestDataTypeEnum.AJAX) return
|
||||||
|
|
||||||
@ -55,8 +58,8 @@ export const useChartDataFetch = (
|
|||||||
clearInterval(fetchInterval)
|
clearInterval(fetchInterval)
|
||||||
|
|
||||||
const fetchFn = async () => {
|
const fetchFn = async () => {
|
||||||
const res: any = await http(requestHttpType.value)(completePath || '', {})
|
const res = await customizeHttp(toRaw(targetComponent.request), toRaw(chartEditStore.requestGlobalConfig))
|
||||||
if (res.data) {
|
if (res && res.data) {
|
||||||
try {
|
try {
|
||||||
const filter = targetComponent.filter
|
const filter = targetComponent.filter
|
||||||
// 更新回调函数
|
// 更新回调函数
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div
|
<div :class="`go-preview ${localStorageInfo.editCanvasConfig.previewScaleType}`">
|
||||||
:class="`go-preview ${localStorageInfo.editCanvasConfig.previewScaleType}`"
|
|
||||||
>
|
|
||||||
<template v-if="showEntity">
|
<template v-if="showEntity">
|
||||||
<!-- 实体区域 -->
|
<!-- 实体区域 -->
|
||||||
<div ref="entityRef" class="go-preview-entity">
|
<div ref="entityRef" class="go-preview-entity">
|
||||||
@ -10,9 +8,7 @@
|
|||||||
<!-- 展示层 -->
|
<!-- 展示层 -->
|
||||||
<div :style="previewRefStyle" v-if="show">
|
<div :style="previewRefStyle" v-if="show">
|
||||||
<!-- 渲染层 -->
|
<!-- 渲染层 -->
|
||||||
<preview-render-list
|
<preview-render-list :localStorageInfo="localStorageInfo"></preview-render-list>
|
||||||
:localStorageInfo="localStorageInfo"
|
|
||||||
></preview-render-list>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -23,9 +19,7 @@
|
|||||||
<!-- 展示层 -->
|
<!-- 展示层 -->
|
||||||
<div :style="previewRefStyle" v-if="show">
|
<div :style="previewRefStyle" v-if="show">
|
||||||
<!-- 渲染层 -->
|
<!-- 渲染层 -->
|
||||||
<preview-render-list
|
<preview-render-list :localStorageInfo="localStorageInfo"></preview-render-list>
|
||||||
:localStorageInfo="localStorageInfo"
|
|
||||||
></preview-render-list>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -43,21 +37,18 @@ import { useStore } from './hooks/useStore.hook'
|
|||||||
import { PreviewScaleEnum } from '@/enums/styleEnum'
|
import { PreviewScaleEnum } from '@/enums/styleEnum'
|
||||||
import type { ChartEditStorageType } from './index.d'
|
import type { ChartEditStorageType } from './index.d'
|
||||||
|
|
||||||
const localStorageInfo: ChartEditStorageType =
|
const localStorageInfo: ChartEditStorageType = getSessionStorageInfo() as ChartEditStorageType
|
||||||
getSessionStorageInfo() as ChartEditStorageType
|
|
||||||
|
|
||||||
const previewRefStyle = computed(() => {
|
const previewRefStyle = computed(() => {
|
||||||
return {
|
return {
|
||||||
...getEditCanvasConfigStyle(localStorageInfo.editCanvasConfig),
|
...getEditCanvasConfigStyle(localStorageInfo.editCanvasConfig),
|
||||||
...getFilterStyle(localStorageInfo.editCanvasConfig),
|
...getFilterStyle(localStorageInfo.editCanvasConfig)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const showEntity = computed(() => {
|
const showEntity = computed(() => {
|
||||||
const type = localStorageInfo.editCanvasConfig.previewScaleType
|
const type = localStorageInfo.editCanvasConfig.previewScaleType
|
||||||
return (
|
return type === PreviewScaleEnum.SCROLL_Y || type === PreviewScaleEnum.SCROLL_X
|
||||||
type === PreviewScaleEnum.SCROLL_Y || type === PreviewScaleEnum.SCROLL_X
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
useStore(localStorageInfo)
|
useStore(localStorageInfo)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user