Skip to content

Commit

Permalink
refactor: refactor useVueCesium method
Browse files Browse the repository at this point in the history
  • Loading branch information
zouyaoji committed Mar 8, 2022
1 parent edd7780 commit 446638d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/composables/use-vue-cesium/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/*
* @Author: zouyaoji@https://github.com/zouyaoji
* @Date: 2021-04-06 09:21:02
* @LastEditTime: 2022-02-25 23:27:55
* @LastEditTime: 2022-03-04 00:59:58
* @LastEditors: zouyaoji
* @Description:
* @FilePath: \vue-cesium@next\packages\composables\use-vue-cesium\index.ts
*/
import { getCurrentInstance } from 'vue'
import { getCurrentInstance, inject } from 'vue'
import { VcViewerProvider } from '@vue-cesium/utils/types'
import useLog from '@vue-cesium/composables/private/use-log'
import { vcKey } from '@vue-cesium/utils/config'

export default function useVueCesium(): VcViewerProvider {
const instance = getCurrentInstance()
const logger = useLog(undefined)
if (instance) {
return instance.appContext.config.globalProperties.$VueCesium as VcViewerProvider
return inject<VcViewerProvider>(vcKey) || (instance.appContext.config.globalProperties.$VueCesium as VcViewerProvider)
} else {
logger.warn('VueCesium useVueCesium() can only be used inside setup().')
}
Expand Down

0 comments on commit 446638d

Please sign in to comment.