From 99cad606e73dd85c362bbe3ab7308391f990a97d Mon Sep 17 00:00:00 2001 From: tnt group <dodu@live.cn> Date: Thu, 22 Sep 2022 09:01:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=20mock=20api=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A2=84=E8=A7=88=E6=A8=A1=E5=BC=8F=E4=B8=8B?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=95=B0=E6=8D=AE=E6=9B=B4=E6=96=B0=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mock/index.ts | 6 +++ src/api/mock/test.mock.ts | 39 +++++++++++++++++++ .../Informations/Mores/WordCloud/index.vue | 15 +++++-- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/api/mock/index.ts b/src/api/mock/index.ts index 413be00c..52f669b9 100644 --- a/src/api/mock/index.ts +++ b/src/api/mock/index.ts @@ -14,6 +14,7 @@ export const scrollBoardUrl = '/mock/scrollBoard' export const radarUrl = '/mock/radarData' export const heatMapUrl = '/mock/heatMapData' export const scatterBasicUrl = '/mock/scatterBasic' +export const wordCloudUrl = '/mock/wordCloud' const mockObject: MockMethod[] = [ { @@ -73,6 +74,11 @@ const mockObject: MockMethod[] = [ method: RequestHttpEnum.GET, response: () => test.fetchScatterBasic }, + { + url: wordCloudUrl, + method: RequestHttpEnum.GET, + response: () => test.fetchWordCloud + } ] export default mockObject diff --git a/src/api/mock/test.mock.ts b/src/api/mock/test.mock.ts index b2a4079a..57e81564 100644 --- a/src/api/mock/test.mock.ts +++ b/src/api/mock/test.mock.ts @@ -198,5 +198,44 @@ export default { status: 200, msg: '请求成功', data: scatterJson + }, + // 词云 + fetchWordCloud: { + code: 0, + status: 200, + msg: '请求成功', + data: [ + { + name: '@name', + value: 8000, + textStyle: { + color: '#78fbb2' + }, + emphasis: { + textStyle: { + color: 'red' + } + } + }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' }, + { name: '@name', value: '@integer(10, 8000)' } + ] } } diff --git a/src/packages/components/Informations/Mores/WordCloud/index.vue b/src/packages/components/Informations/Mores/WordCloud/index.vue index a483dce9..902483dd 100644 --- a/src/packages/components/Informations/Mores/WordCloud/index.vue +++ b/src/packages/components/Informations/Mores/WordCloud/index.vue @@ -23,6 +23,7 @@ import { useChartDataFetch } from '@/hooks' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { isPreview } from '@/utils' import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components' +import dataJson from './data.json' const props = defineProps({ themeSetting: { @@ -47,17 +48,25 @@ const option = computed(() => { return mergeTheme(props.chartConfig.option, props.themeSetting, includes) }) +const dataSetHandle = (dataset: typeof dataJson) => { + // eslint-disable-next-line vue/no-mutating-props + dataset && (props.chartConfig.option.series[0].data = dataset) + + vChartRef.value && isPreview() && vChartRef.value.setOption(props.chartConfig.option) +} + // dataset 无法变更条数的补丁 watch( () => props.chartConfig.option.dataset, newData => { - // eslint-disable-next-line vue/no-mutating-props - props.chartConfig.option.series[0].data = newData + dataSetHandle(newData) }, { deep: false } ) -const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore) +const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore, (newData: typeof dataJson) => { + dataSetHandle(newData) +}) </script>