From 36f9fd2d493308e6aec0587d9d87d103abd08b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Mon, 16 Jan 2023 10:02:26 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E6=97=A0=E6=B3=95=E5=B1=95=E7=A4=BA=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/index.ts | 3 ++- .../components/ChartsSearch/SearchImage.vue | 27 +++++++++++++++++++ .../components/ChartsSearch/index.vue | 3 ++- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/views/chart/ContentCharts/components/ChartsSearch/SearchImage.vue diff --git a/src/packages/index.ts b/src/packages/index.ts index d568afcb..4f530faa 100644 --- a/src/packages/index.ts +++ b/src/packages/index.ts @@ -63,7 +63,8 @@ export const fetchConfigComponent = (dropData: ConfigType) => { * * 获取图片内容 * @param {ConfigType} targetData 配置项 */ -export const fetchImages = async (targetData: ConfigType) => { +export const fetchImages = async (targetData?: ConfigType) => { + if (!targetData) return '' // 新数据动态处理 const { image, package: targetDataPackage } = targetData // 兼容旧数据 diff --git a/src/views/chart/ContentCharts/components/ChartsSearch/SearchImage.vue b/src/views/chart/ContentCharts/components/ChartsSearch/SearchImage.vue new file mode 100644 index 00000000..1cdb6aa9 --- /dev/null +++ b/src/views/chart/ContentCharts/components/ChartsSearch/SearchImage.vue @@ -0,0 +1,27 @@ +<template> + <img v-lazy="imageInfo" alt="展示图" /> +</template> + +<script setup lang="ts"> +import { ref, PropType } from 'vue' +import { ConfigType } from '@/packages/index.d' +import { fetchImages } from '@/packages' + +const props = defineProps({ + item: { + type: Object as PropType<ConfigType>, + } +}) + +const imageInfo = ref('') + +// 获取图片 +const fetchImageUrl = async () => { + imageInfo.value = await fetchImages(props.item) +} +fetchImageUrl() +</script> + +<style scoped> + +</style> \ No newline at end of file diff --git a/src/views/chart/ContentCharts/components/ChartsSearch/index.vue b/src/views/chart/ContentCharts/components/ChartsSearch/index.vue index f0684c86..8f4d8078 100644 --- a/src/views/chart/ContentCharts/components/ChartsSearch/index.vue +++ b/src/views/chart/ContentCharts/components/ChartsSearch/index.vue @@ -37,7 +37,7 @@ :title="item.title" @click="selectChartHandle(item)" > - <img class="list-item-img" v-lazy="item.image" alt="展示图" /> + <search-image class="list-item-img" :item="item"></search-image> <n-text class="list-item-fs" depth="2">{{ item.title }}</n-text> </div> </n-scrollbar> @@ -77,6 +77,7 @@ import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayou import { isString, addEventListener, removeEventListener } from '@/utils' import { fetchConfigComponent, fetchChartComponent } from '@/packages/index' import { componentInstall, loadingStart, loadingFinish, loadingError } from '@/utils' +import SearchImage from './SearchImage.vue' const props = defineProps({ menuOptions: { From f49a55695339459b79c59e6eeab95aca8eb06f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Mon, 16 Jan 2023 12:45:47 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8F=8D=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96=E6=97=A0=E6=B3=95=E5=A4=84=E7=90=86es6?= =?UTF-8?q?=E7=AE=80=E5=86=99=E5=87=BD=E6=95=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/utils.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 858ac9c3..4042eaed 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -321,6 +321,12 @@ export const JSONParse = (data: string) => { return JSON.parse(data, (k, v) => { if (typeof v === 'string' && v.indexOf && (v.indexOf('function') > -1 || v.indexOf('=>') > -1)) { return eval(`(function(){return ${v}})()`) + } else if (typeof v === 'string' && v.indexOf && (v.indexOf('return ') > -1)) { + const baseLeftIndex = v.indexOf('(') + if (baseLeftIndex > -1) { + const newFn = `function ${v.substring(baseLeftIndex)}` + return eval(`(function(){return ${newFn}})()`) + } } return v }) From 651bd976f3ea49e78fd607bc5c40320b758685b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Mon, 16 Jan 2023 17:58:07 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=9B=BE=E7=89=87=E4=B8=8D=E4=BC=9A=E5=8F=98?= =?UTF-8?q?=E5=8A=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Pages/ChartGlobImage/index.ts | 3 +++ .../Pages/ChartGlobImage}/index.vue | 13 ++++++--- .../components/ChartsItemBox/index.vue | 5 ++-- .../components/ChartsItemImage/index.ts | 3 --- .../components/ChartsSearch/SearchImage.vue | 27 ------------------- .../components/ChartsSearch/index.vue | 4 +-- 6 files changed, 18 insertions(+), 37 deletions(-) create mode 100644 src/components/Pages/ChartGlobImage/index.ts rename src/{views/chart/ContentCharts/components/ChartsItemImage => components/Pages/ChartGlobImage}/index.vue (76%) delete mode 100644 src/views/chart/ContentCharts/components/ChartsItemImage/index.ts delete mode 100644 src/views/chart/ContentCharts/components/ChartsSearch/SearchImage.vue diff --git a/src/components/Pages/ChartGlobImage/index.ts b/src/components/Pages/ChartGlobImage/index.ts new file mode 100644 index 00000000..9203fcd7 --- /dev/null +++ b/src/components/Pages/ChartGlobImage/index.ts @@ -0,0 +1,3 @@ +import ChartGlobImage from './index.vue' + +export { ChartGlobImage } diff --git a/src/views/chart/ContentCharts/components/ChartsItemImage/index.vue b/src/components/Pages/ChartGlobImage/index.vue similarity index 76% rename from src/views/chart/ContentCharts/components/ChartsItemImage/index.vue rename to src/components/Pages/ChartGlobImage/index.vue index d5ba9f18..efd6bf41 100644 --- a/src/views/chart/ContentCharts/components/ChartsItemImage/index.vue +++ b/src/components/Pages/ChartGlobImage/index.vue @@ -3,7 +3,7 @@ </template> <script setup lang="ts"> -import { ref, PropType } from 'vue' +import { ref, PropType, watch } from 'vue' import { fetchImages } from '@/packages' import { ConfigType } from '@/packages/index.d' @@ -11,7 +11,7 @@ const props = defineProps({ chartConfig: { type: Object as PropType<ConfigType>, required: true - }, + } }) const imageInfo = ref('') @@ -20,5 +20,12 @@ const imageInfo = ref('') const fetchImageUrl = async () => { imageInfo.value = await fetchImages(props.chartConfig) } -fetchImageUrl() + +watch( + () => props.chartConfig.key, + () => fetchImageUrl(), + { + immediate: true + } +) </script> diff --git a/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue b/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue index b6b9beeb..7ca3b1b0 100644 --- a/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue +++ b/src/views/chart/ContentCharts/components/ChartsItemBox/index.vue @@ -22,7 +22,7 @@ </n-text> </div> <div class="list-center go-flex-center go-transition"> - <charts-item-image class="list-img" :chartConfig="item"></charts-item-image> + <chart-glob-image class="list-img" :chartConfig="item"></chart-glob-image> </div> <div class="list-bottom"> <n-text class="list-bottom-text" depth="3"> @@ -37,7 +37,7 @@ <script setup lang="ts"> import { PropType, watch, ref, Ref, computed, nextTick } from 'vue' import { MacOsControlBtn } from '@/components/Tips/MacOsControlBtn/index' -import { ChartsItemImage } from '../ChartsItemImage' +import { ChartGlobImage } from '@/components/Pages/ChartGlobImage' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { EditCanvasTypeEnum } from '@/store/modules/chartEditStore/chartEditStore.d' import { ChartModeEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d' @@ -47,6 +47,7 @@ import { DragKeyEnum } from '@/enums/editPageEnum' import { createComponent } from '@/packages' import { ConfigType, CreateComponentType } from '@/packages/index.d' import { fetchConfigComponent, fetchChartComponent } from '@/packages/index' + import omit from 'lodash/omit' const chartEditStore = useChartEditStore() diff --git a/src/views/chart/ContentCharts/components/ChartsItemImage/index.ts b/src/views/chart/ContentCharts/components/ChartsItemImage/index.ts deleted file mode 100644 index 698542b4..00000000 --- a/src/views/chart/ContentCharts/components/ChartsItemImage/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -import ChartsItemImage from './index.vue' - -export { ChartsItemImage } diff --git a/src/views/chart/ContentCharts/components/ChartsSearch/SearchImage.vue b/src/views/chart/ContentCharts/components/ChartsSearch/SearchImage.vue deleted file mode 100644 index 1cdb6aa9..00000000 --- a/src/views/chart/ContentCharts/components/ChartsSearch/SearchImage.vue +++ /dev/null @@ -1,27 +0,0 @@ -<template> - <img v-lazy="imageInfo" alt="展示图" /> -</template> - -<script setup lang="ts"> -import { ref, PropType } from 'vue' -import { ConfigType } from '@/packages/index.d' -import { fetchImages } from '@/packages' - -const props = defineProps({ - item: { - type: Object as PropType<ConfigType>, - } -}) - -const imageInfo = ref('') - -// 获取图片 -const fetchImageUrl = async () => { - imageInfo.value = await fetchImages(props.item) -} -fetchImageUrl() -</script> - -<style scoped> - -</style> \ No newline at end of file diff --git a/src/views/chart/ContentCharts/components/ChartsSearch/index.vue b/src/views/chart/ContentCharts/components/ChartsSearch/index.vue index 8f4d8078..f1a25ddd 100644 --- a/src/views/chart/ContentCharts/components/ChartsSearch/index.vue +++ b/src/views/chart/ContentCharts/components/ChartsSearch/index.vue @@ -37,7 +37,7 @@ :title="item.title" @click="selectChartHandle(item)" > - <search-image class="list-item-img" :item="item"></search-image> + <chart-glob-image class="list-item-img" :chartConfig="item"></chart-glob-image> <n-text class="list-item-fs" depth="2">{{ item.title }}</n-text> </div> </n-scrollbar> @@ -77,7 +77,7 @@ import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayou import { isString, addEventListener, removeEventListener } from '@/utils' import { fetchConfigComponent, fetchChartComponent } from '@/packages/index' import { componentInstall, loadingStart, loadingFinish, loadingError } from '@/utils' -import SearchImage from './SearchImage.vue' +import { ChartGlobImage } from '@/components/Pages/ChartGlobImage' const props = defineProps({ menuOptions: {