Skip to content

Commit

Permalink
fix: Fixed analysis component unable to modify button function parame…
Browse files Browse the repository at this point in the history
…ters based on some parameters
  • Loading branch information
flywin8 committed Feb 15, 2023
1 parent e349b09 commit d4b8fa7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 24 deletions.
8 changes: 4 additions & 4 deletions packages/components/analyses/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author: zouyaoji@https://github.com/zouyaoji
* @Date: 2022-01-06 10:23:09
* @LastEditTime: 2023-02-09 18:17:23
* @LastEditTime: 2023-02-15 16:19:01
* @LastEditors: XIAOLIJUN
* @Description:
* @FilePath: \vue-cesium@next\packages\components\analyses\src\index.ts
Expand All @@ -12,7 +12,7 @@ import { defineComponent, getCurrentInstance, reactive, ref, computed, VNode } f
import { useLocale } from '@vue-cesium/composables'
import { defaultOptions, analysesProps, VcAnalysesProps } from './defaultProps'
import type { AnalysisActionCmpRef, VcDrawingActionInstance, VcDrawingOpts, VcViewshedAnalysisOpts } from '@vue-cesium/utils/drawing-types'
import { camelize } from '@vue-cesium/utils/util'
import { camelize, deepMerge } from '@vue-cesium/utils/util'
import type { VcFabActionRef, VcFabProps, VcFabRef } from '@vue-cesium/components/ui'
import useDrawingFab from '@vue-cesium/composables/use-drawing/use-drawing-fab'
import VcAnalysisSightline from './sightline'
Expand Down Expand Up @@ -42,10 +42,10 @@ export default defineComponent({
const fabActionOpts = reactive<VcActionTooltipProps>(Object.assign({}, defaultOptions.fabActionOpts, props.fabActionOpts))

const sightlineActionOpts = reactive<VcActionTooltipProps>(Object.assign({}, defaultOptions.sightlineActionOpts, mergeActionOpts('sightlineActionOpts')))
const sightlineAnalysisOpts = reactive<VcDrawingOpts>(Object.assign({}, defaultOptions.sightlineAnalysisOpts, props.sightlineAnalysisOpts))
const sightlineAnalysisOpts = reactive<VcDrawingOpts>(deepMerge(defaultOptions.sightlineAnalysisOpts, props.sightlineAnalysisOpts))

const viewshedActionOpts = reactive<VcActionTooltipProps>(Object.assign({}, defaultOptions.viewshedActionOpts, mergeActionOpts('viewshedActionOpts')))
const viewshedAnalysisOpts = reactive<VcViewshedAnalysisOpts>(Object.assign({}, defaultOptions.viewshedAnalysisOpts, props.viewshedAnalysisOpts))
const viewshedAnalysisOpts = reactive<VcViewshedAnalysisOpts>(deepMerge(defaultOptions.viewshedAnalysisOpts, props.viewshedAnalysisOpts))

options.sightlineActionOpts = sightlineActionOpts
options.sightlineAnalysisOpts = sightlineAnalysisOpts
Expand Down
16 changes: 8 additions & 8 deletions packages/components/drawings/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineComponent, getCurrentInstance, ref, reactive, VNode, computed } from 'vue'
import { drawingsProps, defaultOptions } from './defaultProps'
import { camelize } from '@vue-cesium/utils/util'
import { camelize, deepMerge } from '@vue-cesium/utils/util'
import type { VcFabActionRef, VcFabProps, VcFabRef } from '@vue-cesium/components/ui'
import type { VcActionTooltipProps, VcComponentInternalInstance, VcComponentPublicInstance } from '@vue-cesium/utils/types'
import VcDrawingPin from './pin'
Expand Down Expand Up @@ -36,19 +36,19 @@ export default defineComponent({
const mainFabOpts = reactive<VcActionTooltipProps & VcFabProps>(Object.assign({}, defaultOptions.mainFabOpts, props.mainFabOpts))
const fabActionOpts = reactive<VcActionTooltipProps>(Object.assign({}, defaultOptions.fabActionOpts, props.fabActionOpts))
const pointActionOpts = reactive<VcActionTooltipProps>(Object.assign({}, defaultOptions.pointActionOpts, mergeActionOpts('pointActionOpts')))
const pointDrawingOpts = reactive<VcDrawingOpts>(Object.assign({}, defaultOptions.pointDrawingOpts, props.pointDrawingOpts))
const pointDrawingOpts = reactive<VcDrawingOpts>(deepMerge(defaultOptions.pointDrawingOpts, props.pointDrawingOpts))
const polylineActionOpts = reactive<VcActionTooltipProps>(Object.assign({}, defaultOptions.polylineActionOpts, mergeActionOpts('polylineActionOpts')))
const polylineDrawingOpts = reactive<VcDrawingOpts>(Object.assign({}, defaultOptions.polylineDrawingOpts, props.polylineDrawingOpts))
const polylineDrawingOpts = reactive<VcDrawingOpts>(deepMerge(defaultOptions.polylineDrawingOpts, props.polylineDrawingOpts))
const polygonActionOpts = reactive<VcActionTooltipProps>(Object.assign({}, defaultOptions.polygonActionOpts, mergeActionOpts('polygonActionOpts')))
const polygonDrawingOpts = reactive<VcDrawingOpts>(Object.assign({}, defaultOptions.polygonDrawingOpts, props.polygonDrawingOpts))
const polygonDrawingOpts = reactive<VcDrawingOpts>(deepMerge(defaultOptions.polygonDrawingOpts, props.polygonDrawingOpts))
const rectangleActionOpts = reactive<VcActionTooltipProps>(Object.assign({}, defaultOptions.rectangleActionOpts, mergeActionOpts('rectangleActionOpts')))
const rectangleDrawingOpts = reactive<VcDrawingOpts>(Object.assign({}, defaultOptions.rectangleDrawingOpts, props.rectangleDrawingOpts))
const rectangleDrawingOpts = reactive<VcDrawingOpts>(deepMerge(defaultOptions.rectangleDrawingOpts, props.rectangleDrawingOpts))
const circleActionOpts = reactive<VcActionTooltipProps>(Object.assign({}, defaultOptions.circleActionOpts, mergeActionOpts('circleActionOpts')))
const circleDrawingOpts = reactive<VcDrawingOpts>(Object.assign({}, defaultOptions.circleDrawingOpts, props.circleDrawingOpts))
const circleDrawingOpts = reactive<VcDrawingOpts>(deepMerge(defaultOptions.circleDrawingOpts, props.circleDrawingOpts))
const regularActionOpts = reactive<VcActionTooltipProps>(Object.assign({}, defaultOptions.regularActionOpts, mergeActionOpts('regularActionOpts')))
const regularDrawingOpts = reactive<VcDrawingOpts>(Object.assign({}, defaultOptions.regularDrawingOpts, props.regularDrawingOpts))
const regularDrawingOpts = reactive<VcDrawingOpts>(deepMerge(defaultOptions.regularDrawingOpts, props.regularDrawingOpts))
const pinActionOpts = reactive<VcActionTooltipProps>(Object.assign({}, defaultOptions.pinActionOpts, mergeActionOpts('pinActionOpts')))
const pinDrawingOpts = reactive<VcDrawingOpts>(Object.assign({}, defaultOptions.pinDrawingOpts, props.pinDrawingOpts))
const pinDrawingOpts = reactive<VcDrawingOpts>(deepMerge(defaultOptions.pinDrawingOpts, props.pinDrawingOpts))

options.pointActionOpts = pointActionOpts
options.pointDrawingOpts = pointDrawingOpts
Expand Down
24 changes: 12 additions & 12 deletions packages/components/measurements/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineComponent, getCurrentInstance, ref, reactive, computed, VNode } from 'vue'
import { measurementsProps, defaultOptions, VcMeasurementsProps } from './defaultProps'
import { camelize } from '@vue-cesium/utils/util'
import { camelize, deepMerge } from '@vue-cesium/utils/util'
import { VcFabActionRef, VcFabProps, VcFabRef } from '@vue-cesium/components/ui'
import VcMeasurementDistance from './distance'
import VcMeasurementPolyline from './polyline'
Expand Down Expand Up @@ -49,63 +49,63 @@ export default defineComponent({
Object.assign({}, defaultOptions.distanceActionOpts, mergeActionOpts('distanceActionOpts'))
)
const distanceMeasurementOpts = reactive<VcMeasurementOpts>(
Object.assign({}, defaultOptions.distanceMeasurementOpts, props.distanceMeasurementOpts)
deepMerge(defaultOptions.distanceMeasurementOpts, props.distanceMeasurementOpts)
)

const componentDistanceActionOpts = reactive<VcActionTooltipProps>(
Object.assign({}, defaultOptions.componentDistanceActionOpts, mergeActionOpts('componentDistanceActionOpts'))
)
const componentDistanceMeasurementOpts = reactive<VcComponentDistanceMeasurementOpts>(
Object.assign({}, defaultOptions.componentDistanceMeasurementOpts, props.componentDistanceMeasurementOpts)
deepMerge(defaultOptions.componentDistanceMeasurementOpts, props.componentDistanceMeasurementOpts)
)

const polylineActionOpts = reactive<VcActionTooltipProps>(
Object.assign({}, defaultOptions.polylineActionOpts, mergeActionOpts('polylineActionOpts'))
)
const polylineMeasurementOpts = reactive<VcPolylineMeasurementOpts>(
Object.assign({}, defaultOptions.polylineMeasurementOpts, props.polylineMeasurementOpts)
deepMerge(defaultOptions.polylineMeasurementOpts, props.polylineMeasurementOpts)
)

const horizontalActionOpts = reactive<VcActionTooltipProps>(
Object.assign({}, defaultOptions.horizontalActionOpts, mergeActionOpts('horizontalActionOpts'))
)
const horizontalMeasurementOpts = reactive<VcHorizontalMeasurementOpts>(
Object.assign({}, defaultOptions.horizontalMeasurementOpts, props.horizontalMeasurementOpts)
deepMerge(defaultOptions.horizontalMeasurementOpts, props.horizontalMeasurementOpts)
)

const verticalActionOpts = reactive<VcActionTooltipProps>(
Object.assign({}, defaultOptions.verticalActionOpts, mergeActionOpts('verticalActionOpts'))
)
const verticalMeasurementOpts = reactive<VcMeasurementOpts>(
Object.assign({}, defaultOptions.verticalMeasurementOpts, props.verticalMeasurementOpts)
deepMerge(defaultOptions.verticalMeasurementOpts, props.verticalMeasurementOpts)
)

const heightActionOpts = reactive<VcActionTooltipProps>(Object.assign({}, defaultOptions.heightActionOpts, mergeActionOpts('heightActionOpts')))
const heightMeasurementOpts = reactive<VcMeasurementOpts>(Object.assign({}, defaultOptions.heightMeasurementOpts, props.heightMeasurementOpts))
const heightMeasurementOpts = reactive<VcMeasurementOpts>(deepMerge(defaultOptions.heightMeasurementOpts, props.heightMeasurementOpts))

const areaActionOpts = reactive<VcActionTooltipProps>(Object.assign({}, defaultOptions.areaActionOpts, mergeActionOpts('areaActionOpts')))
const areaMeasurementOpts = reactive<VcPolylineMeasurementOpts>(Object.assign({}, defaultOptions.areaMeasurementOpts, props.areaMeasurementOpts))
const areaMeasurementOpts = reactive<VcPolylineMeasurementOpts>(deepMerge(defaultOptions.areaMeasurementOpts, props.areaMeasurementOpts))

const pointActionOpts = reactive<VcActionTooltipProps>(Object.assign({}, defaultOptions.pointActionOpts, mergeActionOpts('pointActionOpts')))
const pointMeasurementOpts = reactive<VcMeasurementOpts>(Object.assign({}, defaultOptions.pointMeasurementOpts, props.pointMeasurementOpts))
const pointMeasurementOpts = reactive<VcMeasurementOpts>(deepMerge(defaultOptions.pointMeasurementOpts, props.pointMeasurementOpts))

const rectangleActionOpts = reactive<VcActionTooltipProps>(
Object.assign({}, defaultOptions.rectangleActionOpts, mergeActionOpts('rectangleActionOpts'))
)
const rectangleMeasurementOpts = reactive<VcRegularMeasurementOpts>(
Object.assign({}, defaultOptions.rectangleMeasurementOpts, props.rectangleMeasurementOpts)
deepMerge(defaultOptions.rectangleMeasurementOpts, props.rectangleMeasurementOpts)
)

const regularActionOpts = reactive<VcActionTooltipProps>(
Object.assign({}, defaultOptions.regularActionOpts, mergeActionOpts('regularActionOpts'))
)
const regularMeasurementOpts = reactive<VcRegularMeasurementOpts>(
Object.assign({}, defaultOptions.regularMeasurementOpts, props.regularMeasurementOpts)
deepMerge(defaultOptions.regularMeasurementOpts, props.regularMeasurementOpts)
)

const circleActionOpts = reactive<VcActionTooltipProps>(Object.assign({}, defaultOptions.circleActionOpts, mergeActionOpts('circleActionOpts')))
const circleMeasurementOpts = reactive<VcRegularMeasurementOpts>(
Object.assign({}, defaultOptions.circleMeasurementOpts, props.circleMeasurementOpts)
deepMerge(defaultOptions.circleMeasurementOpts, props.circleMeasurementOpts)
)

const options: any = {}
Expand Down
9 changes: 9 additions & 0 deletions packages/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,15 @@ export function isArrayLike(obj) {
return typeof length === 'number' && length >= 0
}

// 深度合并
export function deepMerge<T = any>(src: any = {}, target: any = {}): T {
let key: string
for (key in target) {
src[key] = isObject(src[key]) ? deepMerge(src[key], target[key]) : (src[key] = target[key])
}
return src
}

// reexport from lodash & vue shared
export {
hasOwn,
Expand Down

0 comments on commit d4b8fa7

Please sign in to comment.