Skip to content

Commit

Permalink
refactor(vue-cesium): ♻️ ready event parameter of all components be…
Browse files Browse the repository at this point in the history
…comes instance.
  • Loading branch information
zouyaoji committed May 6, 2023
1 parent bd81be0 commit a581478
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/components/viewer/src/useViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ export default function (props: VcViewerProps, ctx, vcInstance: VcComponentInter
const readyObj: VcReadyObject = {
Cesium,
viewer,
vm: vcInstance.proxy as VcViewerRef
vm: vcInstance
}
if (globalThis.XE) {
Object.assign(readyObj, {
Expand Down
2 changes: 1 addition & 1 deletion packages/composables/use-common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default function (props, { emit, attrs }, vcInstance: VcComponentInternal
cesiumObject: vcInstance.cesiumObject
})
// Trigger the component's 'ready' event. 触发该组件的 'ready' 事件。
const readyObj: VcReadyObject = { Cesium, viewer, cesiumObject, vm: vcInstance.proxy as VcComponentPublicInstance }
const readyObj: VcReadyObject = { Cesium, viewer, cesiumObject, vm: vcInstance }
emit('ready', readyObj)
vcMitt.emit('ready', readyObj)
logger.debug(`${vcInstance.cesiumClass}---loaded`)
Expand Down
76 changes: 75 additions & 1 deletion packages/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { VcBtnProps, VcFabActionProps, VcTooltipProps } from '@vue-cesium/c
import type MouseCoords from '@vue-cesium/components/controls/status-bar/MouseCoords'
import AMapImageryProvider from '@vue-cesium/components/providers/amap/AMapImageryProvider'
import TencentImageryProvider from '@vue-cesium/components/providers/tencent/TencentImageryProvider'
import { VcPointProps } from '@vue-cesium/components/primitive-collections'

interface AnyObject {
[propName: string]: any
Expand All @@ -19,7 +20,8 @@ interface VcReadyObject {
Cesium: typeof Cesium
viewer: Cesium.Viewer
cesiumObject?: VcCesiumObject | Array<VcCesiumObject>
vm?: VcComponentPublicInstance
// vm?: VcComponentPublicInstance VcComponentInternalInstance
vm?: VcComponentInternalInstance
earth?: any
map?: any
}
Expand Down Expand Up @@ -716,6 +718,78 @@ export type VueClassProp = string | Array<VueClassProp> | VueClassObjectProp

export type VueStyleObjectProp = Partial<CSSStyleDeclaration>

export type VcTyphoonDatasource = {
name: string
typhoonRoute: VcTyphoonRoute | VcTyphoonRouteForecast
show: boolean
points?: VcTyphoonPoint[]
colors?: VcColor[]
positions: VcPosition[]
playInterval?: any
playIndex?: number
children?: VcTyphoonDatasource[]
type?: 'live' | 'forc'
}

export type VcTyphoonRoute = {
begin_time: string
ename: string
end_time: string
ident: string
is_current: 1
land: any[]
name: string
points: VcTyphoonPoint[]
tfbh: string
}

export type VcTyphoonRouteForecast = {
sets: string
points: VcTyphoonPoint[]
unshifted?: boolean
name?: string
}

export type VcTyphoonPoint = {
id?: string
time: string
lng: number
lat: number
strong: string
power: number
speed: number
move_dir: string
move_speed: number
pressure: number
radius7: number
radius10: number
radius12: number
radius7_quad?: {
ne: number
se: number
sw: number
nw: number
}
radius10_quad?: {
ne: number
se: number
sw: number
nw: number
}
radius12_quad?: {
ne: number
se: number
sw: number
nw: number
}
remark: string
forecast?: VcTyphoonRouteForecast[]
type?: 'live' | 'forc'
index?: number
tfbh?: string
sets?: string
} & VcPointProps

export {
AnyObject,
VcCamera,
Expand Down

0 comments on commit a581478

Please sign in to comment.