Skip to content

Commit

Permalink
refactor(analyses): improve types
Browse files Browse the repository at this point in the history
  • Loading branch information
zouyaoji committed Mar 8, 2022
1 parent 27626ef commit 1451fb1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
22 changes: 18 additions & 4 deletions packages/components/analyses/flood/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* @Author: zouyaoji@https://github.com/zouyaoji
* @Date: 2021-12-31 10:30:21
* @LastEditTime: 2022-02-17 17:40:47
* @LastEditTime: 2022-03-05 15:38:26
* @LastEditors: zouyaoji
* @Description:
* @FilePath: \vue-cesium@next\packages\components\analyses\flood\index.ts
Expand Down Expand Up @@ -47,7 +47,7 @@ export default defineComponent({
...polygonHierarchy
},
emits: emits,
setup(props, ctx) {
setup(props: VcAnalysisFloodProps, ctx) {
const instance = getCurrentInstance() as VcComponentInternalInstance
instance.cesiumClass = 'VcAnalysisFlood'
instance.cesiumEvents = []
Expand Down Expand Up @@ -151,7 +151,6 @@ export default defineComponent({

// expose public methods
Object.assign(instance.proxy, {
childRef,
start,
pause,
stop
Expand Down Expand Up @@ -188,7 +187,7 @@ export default defineComponent({
}
})

export type VcAnalysisFloodProps = {
export interface VcAnalysisFloodProps {
/**
* Specify the minimum elevation.
* Default value: -1
Expand Down Expand Up @@ -235,3 +234,18 @@ export type VcAnalysisFloodProps = {
*/
onStop?: (evt: Cesium.ClassificationPrimitive) => void
}

export interface VcAnalysisFloodRef extends VcComponentPublicInstance<VcAnalysisFloodProps> {
/**
* Start flood analysis
*/
start: () => void
/**
* Pause flood analysis
*/
pause: () => void
/**
* Stop flood analysis
*/
stop: () => void
}
12 changes: 5 additions & 7 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: 2022-02-18 23:45:13
* @LastEditTime: 2022-03-06 22:17:24
* @LastEditors: zouyaoji
* @Description:
* @FilePath: \vue-cesium@next\packages\components\analyses\src\index.ts
Expand All @@ -20,9 +20,7 @@ import {
viewshedAnalysisActionDefault
} from './defaultProps'
import {
AnalysisActionCmpOpts,
AnalysisActionCmpRef,
AnalysisActionOpts,
VcDrawingActionInstance,
VcDrawingActiveEvt,
VcDrawingDrawEvt,
Expand All @@ -32,7 +30,7 @@ import {
VcViewshedAnalysisOpts
} from '@vue-cesium/utils/drawing-types'
import { camelize } from '@vue-cesium/utils/util'
import { VcFabAction, VcFabProps } from '@vue-cesium/components/ui'
import { VcFabActionRef, VcFabProps } from '@vue-cesium/components/ui'
import useDrawingFab from '@vue-cesium/composables/use-drawing/use-drawing-fab'
import VcAnalysisSightline from './sightline'
import VcAnalysisViewshed from './viewshed'
Expand Down Expand Up @@ -87,11 +85,11 @@ export default defineComponent({
actionClass: `vc-analysis-${analysisName} vc-analysis-button${
analysisName === (instance.proxy as any).selectedDrawingActionInstance?.name ? ' active' : ''
}`,
actionRef: ref<typeof VcFabAction>(null!),
actionOpts: options[`${camelize(analysisName)}ActionOpts`] as AnalysisActionOpts,
actionRef: ref<VcFabActionRef>(null),
actionOpts: options[`${camelize(analysisName)}ActionOpts`] as VcActionTooltipProps,
cmp: getDrawingCmp(analysisName),
cmpRef: ref<AnalysisActionCmpRef>(null!),
cmpOpts: options[`${camelize(analysisName)}AnalysisOpts`] as AnalysisActionCmpOpts,
cmpOpts: options[`${camelize(analysisName)}AnalysisOpts`] as VcDrawingOpts,
tip: options[`${camelize(analysisName)}ActionOpts`].tooltip.tip || t(`vc.analysis.${camelize(analysisName)}.tip`),
isActive: false
}))
Expand Down

0 comments on commit 1451fb1

Please sign in to comment.