Skip to content

Commit

Permalink
refactor(vue-maplibre): ♻️ 修复 use-common 中父组件不是 vue-maplibre 库的组件导致…
Browse files Browse the repository at this point in the history
…加载失败的问题
  • Loading branch information
zouyaoji committed Aug 17, 2024
1 parent 1a2b99b commit 1b8e348
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.en-US.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
## Changelog

### 0.0.14

_2024-08-17_

#### Bug 修复

- Fixed the issue in use-common that loading fails if the parent component is not a component from the vue-maplibre library.

### 0.0.12

_2024-08-04_
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
## 更新日志

### 0.0.14

_2024-08-17_

#### Bug 修复

- 修复 `use-common` 中父组件不是 vue-maplibre 库的组件导致加载失败的问题。


### 0.0.12

_2024-08-04_
Expand Down
6 changes: 3 additions & 3 deletions packages/composables/use-common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Date: 2024-04-16 22:46:21
* @Description: Do not edit
* @LastEditors: zouyaoji 370681295@qq.com
* @LastEditTime: 2024-08-13 17:58:54
* @LastEditTime: 2024-08-17 22:37:42
* @FilePath: \vue-maplibre\packages\composables\use-common\index.ts
*/
import { VmComponentInternalInstance, VmComponentPublicInstance, VmMapProvider, VmMittEvents, VmReadyObject } from '@vue-maplibre/utils/types'
Expand Down Expand Up @@ -55,7 +55,7 @@ export default function (props, { emit, attrs }, instance: VmComponentInternalIn
const load = async () => {
// Returns if it is already loaded. 如果已经加载则返回。
if (instance.mounted) {
return false
return Promise.resolve(false)
}

logger.debug(`${instance.className}---loading`)
Expand All @@ -67,7 +67,7 @@ export default function (props, { emit, attrs }, instance: VmComponentInternalIn

// If you call the unload method to unload the component, the instance of the parent component may be unloaded. You need to load the parent component first.
// 如果调用过 unload 方法卸载组件,父组件的对象可能会被卸载 需要先加载父组件。
if (!parentInstance.maplibreObject && !parentInstance.nowaiting && !isMapRoot) {
if (!parentInstance.maplibreObject && !parentInstance.nowaiting && !isMapRoot && parentInstance.className) {
return await (parentInstance.proxy as VmComponentPublicInstance)?.load()
}

Expand Down

0 comments on commit 1b8e348

Please sign in to comment.