feat: 新增数据池 hook

This commit is contained in:
奔跑的面条
2022-11-15 21:25:35 +08:00
parent 80e5dbd9cb
commit 649ab1fe8c
8 changed files with 143 additions and 15 deletions
@@ -125,7 +125,7 @@ const sendHandle = async () => {
if (!targetData.value?.request) return
loading.value = true
try {
const res = await customizeHttp(toRaw(targetData.value.request), toRaw(chartEditStore.requestGlobalConfig))
const res = await customizeHttp(toRaw(targetData.value.request), toRaw(chartEditStore.getRequestGlobalConfig))
loading.value = false
if (res) {
if(!res?.data && !targetData.value.filter) window['$message'].warning('您的数据不符合默认格式,请配置过滤器!')
@@ -128,7 +128,7 @@ const sourceData = ref<any>('')
// 动态获取数据
const fetchTargetData = async () => {
try {
const res = await customizeHttp(toRaw(targetData.value.request), toRaw(chartEditStore.requestGlobalConfig))
const res = await customizeHttp(toRaw(targetData.value.request), toRaw(chartEditStore.getRequestGlobalConfig))
if (res) {
sourceData.value = res
return
@@ -10,7 +10,7 @@
...getTransformStyle(item.styles),
...getStatusStyle(item.status),
...getBlendModeStyle(item.styles) as any
} as any"
}"
>
<!-- 分组 -->
<preview-render-group
@@ -36,7 +36,8 @@
</template>
<script setup lang="ts">
import { PropType, computed } from 'vue'
import { PropType, computed, onMounted } from 'vue'
import { useChartDataPondFetch } from '@/hooks'
import { ChartEditStorageType } from '../../index.d'
import { PreviewRenderGroup } from '../PreviewRenderGroup/index'
import { CreateComponentGroupType } from '@/packages/index.d'
@@ -45,6 +46,9 @@ import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle }
import { getSizeStyle, getComponentAttrStyle, getStatusStyle } from '../../utils'
import { useLifeHandler } from '@/hooks'
// 初始化数据池
const { initDataPond } = useChartDataPondFetch()
const props = defineProps({
localStorageInfo: {
type: Object as PropType<ChartEditStorageType>,
@@ -63,6 +67,11 @@ const themeColor = computed(() => {
const chartThemeColor = props.localStorageInfo.editCanvasConfig.chartThemeColor
return chartColors[chartThemeColor]
})
// 组件渲染结束初始化数据池
onMounted(() => {
initDataPond(props.localStorageInfo.requestGlobalConfig)
})
</script>
<style lang="scss" scoped>