From eb446c8104cbf29c95eafedacc72492fe6b333b6 Mon Sep 17 00:00:00 2001 From: XIAOLIJUN Date: Wed, 15 Feb 2023 17:41:14 +0800 Subject: [PATCH] fix: Fixed deep copy of the analysis component binding function button parameter object --- packages/components/analyses/src/index.ts | 8 +++--- packages/components/drawings/src/index.ts | 16 ++++++------ packages/components/measurements/src/index.ts | 26 ++++++++++--------- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/packages/components/analyses/src/index.ts b/packages/components/analyses/src/index.ts index bb9b8a51..87788d56 100644 --- a/packages/components/analyses/src/index.ts +++ b/packages/components/analyses/src/index.ts @@ -1,7 +1,7 @@ /* * @Author: zouyaoji@https://github.com/zouyaoji * @Date: 2022-01-06 10:23:09 - * @LastEditTime: 2023-02-15 16:19:01 + * @LastEditTime: 2023-02-15 17:28:18 * @LastEditors: XIAOLIJUN * @Description: * @FilePath: \vue-cesium@next\packages\components\analyses\src\index.ts @@ -18,7 +18,7 @@ import useDrawingFab from '@vue-cesium/composables/use-drawing/use-drawing-fab' import VcAnalysisSightline from './sightline' import VcAnalysisViewshed from './viewshed' import { drawingEmit } from '@vue-cesium/utils/emits' -import { isEqual } from 'lodash-es' +import { cloneDeep, isEqual } from 'lodash-es' const emits = { ...drawingEmit, @@ -42,10 +42,10 @@ export default defineComponent({ const fabActionOpts = reactive(Object.assign({}, defaultOptions.fabActionOpts, props.fabActionOpts)) const sightlineActionOpts = reactive(Object.assign({}, defaultOptions.sightlineActionOpts, mergeActionOpts('sightlineActionOpts'))) - const sightlineAnalysisOpts = reactive(deepMerge(defaultOptions.sightlineAnalysisOpts, props.sightlineAnalysisOpts)) + const sightlineAnalysisOpts = reactive(deepMerge(cloneDeep(defaultOptions.sightlineAnalysisOpts), props.sightlineAnalysisOpts)) const viewshedActionOpts = reactive(Object.assign({}, defaultOptions.viewshedActionOpts, mergeActionOpts('viewshedActionOpts'))) - const viewshedAnalysisOpts = reactive(deepMerge(defaultOptions.viewshedAnalysisOpts, props.viewshedAnalysisOpts)) + const viewshedAnalysisOpts = reactive(deepMerge(cloneDeep(defaultOptions.viewshedAnalysisOpts), props.viewshedAnalysisOpts)) options.sightlineActionOpts = sightlineActionOpts options.sightlineAnalysisOpts = sightlineAnalysisOpts diff --git a/packages/components/drawings/src/index.ts b/packages/components/drawings/src/index.ts index 90aa7813..ace4e599 100644 --- a/packages/components/drawings/src/index.ts +++ b/packages/components/drawings/src/index.ts @@ -14,7 +14,7 @@ import useDrawingFab from '@vue-cesium/composables/use-drawing/use-drawing-fab' import { useLocale } from '@vue-cesium/composables' import { drawingEmit } from '@vue-cesium/utils/emits' import { VcDrawingsProps } from '..' -import { isEqual } from 'lodash-es' +import { cloneDeep, isEqual } from 'lodash-es' const emits = { ...drawingEmit, @@ -36,19 +36,19 @@ export default defineComponent({ const mainFabOpts = reactive(Object.assign({}, defaultOptions.mainFabOpts, props.mainFabOpts)) const fabActionOpts = reactive(Object.assign({}, defaultOptions.fabActionOpts, props.fabActionOpts)) const pointActionOpts = reactive(Object.assign({}, defaultOptions.pointActionOpts, mergeActionOpts('pointActionOpts'))) - const pointDrawingOpts = reactive(deepMerge(defaultOptions.pointDrawingOpts, props.pointDrawingOpts)) + const pointDrawingOpts = reactive(deepMerge(cloneDeep(defaultOptions.pointDrawingOpts), props.pointDrawingOpts)) const polylineActionOpts = reactive(Object.assign({}, defaultOptions.polylineActionOpts, mergeActionOpts('polylineActionOpts'))) - const polylineDrawingOpts = reactive(deepMerge(defaultOptions.polylineDrawingOpts, props.polylineDrawingOpts)) + const polylineDrawingOpts = reactive(deepMerge(cloneDeep(defaultOptions.polylineDrawingOpts), props.polylineDrawingOpts)) const polygonActionOpts = reactive(Object.assign({}, defaultOptions.polygonActionOpts, mergeActionOpts('polygonActionOpts'))) - const polygonDrawingOpts = reactive(deepMerge(defaultOptions.polygonDrawingOpts, props.polygonDrawingOpts)) + const polygonDrawingOpts = reactive(deepMerge(cloneDeep(defaultOptions.polygonDrawingOpts), props.polygonDrawingOpts)) const rectangleActionOpts = reactive(Object.assign({}, defaultOptions.rectangleActionOpts, mergeActionOpts('rectangleActionOpts'))) - const rectangleDrawingOpts = reactive(deepMerge(defaultOptions.rectangleDrawingOpts, props.rectangleDrawingOpts)) + const rectangleDrawingOpts = reactive(deepMerge(cloneDeep(defaultOptions.rectangleDrawingOpts), props.rectangleDrawingOpts)) const circleActionOpts = reactive(Object.assign({}, defaultOptions.circleActionOpts, mergeActionOpts('circleActionOpts'))) - const circleDrawingOpts = reactive(deepMerge(defaultOptions.circleDrawingOpts, props.circleDrawingOpts)) + const circleDrawingOpts = reactive(deepMerge(cloneDeep(defaultOptions.circleDrawingOpts), props.circleDrawingOpts)) const regularActionOpts = reactive(Object.assign({}, defaultOptions.regularActionOpts, mergeActionOpts('regularActionOpts'))) - const regularDrawingOpts = reactive(deepMerge(defaultOptions.regularDrawingOpts, props.regularDrawingOpts)) + const regularDrawingOpts = reactive(deepMerge(cloneDeep(defaultOptions.regularDrawingOpts), props.regularDrawingOpts)) const pinActionOpts = reactive(Object.assign({}, defaultOptions.pinActionOpts, mergeActionOpts('pinActionOpts'))) - const pinDrawingOpts = reactive(deepMerge(defaultOptions.pinDrawingOpts, props.pinDrawingOpts)) + const pinDrawingOpts = reactive(deepMerge(cloneDeep(defaultOptions.pinDrawingOpts), props.pinDrawingOpts)) options.pointActionOpts = pointActionOpts options.pointDrawingOpts = pointDrawingOpts diff --git a/packages/components/measurements/src/index.ts b/packages/components/measurements/src/index.ts index 8925bfbe..a83fc49c 100644 --- a/packages/components/measurements/src/index.ts +++ b/packages/components/measurements/src/index.ts @@ -24,7 +24,7 @@ import type { VcActionTooltipProps, VcComponentInternalInstance, VcComponentPubl import { useLocale } from '@vue-cesium/composables' import useDrawingFab from '@vue-cesium/composables/use-drawing/use-drawing-fab' import { drawingEmit } from '@vue-cesium/utils/emits' -import { isEqual } from 'lodash-es' +import { isEqual, cloneDeep } from 'lodash-es' const emits = { ...drawingEmit, @@ -49,63 +49,65 @@ export default defineComponent({ Object.assign({}, defaultOptions.distanceActionOpts, mergeActionOpts('distanceActionOpts')) ) const distanceMeasurementOpts = reactive( - deepMerge(defaultOptions.distanceMeasurementOpts, props.distanceMeasurementOpts) + deepMerge(cloneDeep(defaultOptions.distanceMeasurementOpts), props.distanceMeasurementOpts) ) const componentDistanceActionOpts = reactive( Object.assign({}, defaultOptions.componentDistanceActionOpts, mergeActionOpts('componentDistanceActionOpts')) ) const componentDistanceMeasurementOpts = reactive( - deepMerge(defaultOptions.componentDistanceMeasurementOpts, props.componentDistanceMeasurementOpts) + deepMerge(cloneDeep(defaultOptions.componentDistanceMeasurementOpts), props.componentDistanceMeasurementOpts) ) const polylineActionOpts = reactive( Object.assign({}, defaultOptions.polylineActionOpts, mergeActionOpts('polylineActionOpts')) ) const polylineMeasurementOpts = reactive( - deepMerge(defaultOptions.polylineMeasurementOpts, props.polylineMeasurementOpts) + deepMerge(cloneDeep(defaultOptions.polylineMeasurementOpts), props.polylineMeasurementOpts) ) const horizontalActionOpts = reactive( Object.assign({}, defaultOptions.horizontalActionOpts, mergeActionOpts('horizontalActionOpts')) ) const horizontalMeasurementOpts = reactive( - deepMerge(defaultOptions.horizontalMeasurementOpts, props.horizontalMeasurementOpts) + deepMerge(cloneDeep(defaultOptions.horizontalMeasurementOpts), props.horizontalMeasurementOpts) ) const verticalActionOpts = reactive( Object.assign({}, defaultOptions.verticalActionOpts, mergeActionOpts('verticalActionOpts')) ) const verticalMeasurementOpts = reactive( - deepMerge(defaultOptions.verticalMeasurementOpts, props.verticalMeasurementOpts) + deepMerge(cloneDeep(defaultOptions.verticalMeasurementOpts), props.verticalMeasurementOpts) ) const heightActionOpts = reactive(Object.assign({}, defaultOptions.heightActionOpts, mergeActionOpts('heightActionOpts'))) - const heightMeasurementOpts = reactive(deepMerge(defaultOptions.heightMeasurementOpts, props.heightMeasurementOpts)) + const heightMeasurementOpts = reactive(deepMerge(cloneDeep(defaultOptions.heightMeasurementOpts), props.heightMeasurementOpts)) const areaActionOpts = reactive(Object.assign({}, defaultOptions.areaActionOpts, mergeActionOpts('areaActionOpts'))) - const areaMeasurementOpts = reactive(deepMerge(defaultOptions.areaMeasurementOpts, props.areaMeasurementOpts)) + const areaMeasurementOpts = reactive( + deepMerge(cloneDeep(defaultOptions.areaMeasurementOpts), props.areaMeasurementOpts) + ) const pointActionOpts = reactive(Object.assign({}, defaultOptions.pointActionOpts, mergeActionOpts('pointActionOpts'))) - const pointMeasurementOpts = reactive(deepMerge(defaultOptions.pointMeasurementOpts, props.pointMeasurementOpts)) + const pointMeasurementOpts = reactive(deepMerge(cloneDeep(defaultOptions.pointMeasurementOpts), props.pointMeasurementOpts)) const rectangleActionOpts = reactive( Object.assign({}, defaultOptions.rectangleActionOpts, mergeActionOpts('rectangleActionOpts')) ) const rectangleMeasurementOpts = reactive( - deepMerge(defaultOptions.rectangleMeasurementOpts, props.rectangleMeasurementOpts) + deepMerge(cloneDeep(defaultOptions.rectangleMeasurementOpts), props.rectangleMeasurementOpts) ) const regularActionOpts = reactive( Object.assign({}, defaultOptions.regularActionOpts, mergeActionOpts('regularActionOpts')) ) const regularMeasurementOpts = reactive( - deepMerge(defaultOptions.regularMeasurementOpts, props.regularMeasurementOpts) + deepMerge(cloneDeep(defaultOptions.regularMeasurementOpts), props.regularMeasurementOpts) ) const circleActionOpts = reactive(Object.assign({}, defaultOptions.circleActionOpts, mergeActionOpts('circleActionOpts'))) const circleMeasurementOpts = reactive( - deepMerge(defaultOptions.circleMeasurementOpts, props.circleMeasurementOpts) + deepMerge(cloneDeep(defaultOptions.circleMeasurementOpts), props.circleMeasurementOpts) ) const options: any = {}