From f285e3334ef4f3811e648523d2f06b40c260451e Mon Sep 17 00:00:00 2001 From: Hunter Date: Wed, 18 Jan 2023 03:28:28 +0800 Subject: [PATCH] fix: not use destructure syntax --- .../src/components/ModalsContainer.vue | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/vue-final-modal/src/components/ModalsContainer.vue b/packages/vue-final-modal/src/components/ModalsContainer.vue index 5c6b9c1f..c702cd6c 100644 --- a/packages/vue-final-modal/src/components/ModalsContainer.vue +++ b/packages/vue-final-modal/src/components/ModalsContainer.vue @@ -5,16 +5,16 @@ import type { Ref } from 'vue' import type { UseModalOptionsPrivate } from '../Modal' import { useInternalVfm, useVfm } from '~/useApi' -const { modalsContainers, dynamicModals } = useVfm() -const { resolvedClosed, resolvedOpened } = useInternalVfm() +const vfm = useVfm() +const _vfm = useInternalVfm() const uid = Symbol('ModalsContainer') -const shouldMount = computed(() => uid === modalsContainers.value[0]) +const shouldMount = computed(() => uid === vfm.modalsContainers.value?.[0]) const openedDynamicModals: Ref = shallowRef([]) function syncOpenDynamicModals() { - openedDynamicModals.value = dynamicModals.filter(modal => modal.modelValue) + openedDynamicModals.value = vfm.dynamicModals.filter(modal => modal.modelValue) } function withSyncOpenDynamicModals(callbackFn?: () => void) { @@ -22,7 +22,7 @@ function withSyncOpenDynamicModals(callbackFn?: () => void) { syncOpenDynamicModals() } -watch(() => dynamicModals.map(modal => modal.modelValue), (value, oldValue) => { +watch(() => vfm.dynamicModals?.map(modal => modal.modelValue), (value, oldValue) => { if (!oldValue || value.length !== oldValue.length) { syncOpenDynamicModals() return @@ -44,9 +44,9 @@ watch(() => dynamicModals.map(modal => modal.modelValue), (value, oldValue) => { immediate: true, }) -modalsContainers.value.push(uid) +vfm.modalsContainers.value.push(uid) onBeforeUnmount(() => { - modalsContainers.value = modalsContainers.value.filter(i => i !== uid) + vfm.modalsContainers.value = vfm.modalsContainers.value.filter(i => i !== uid) }) @@ -58,8 +58,8 @@ onBeforeUnmount(() => { :key="modal.id" v-bind="modal.attrs" v-model="modal.modelValue" - @closed="withSyncOpenDynamicModals(() => resolvedClosed(index))" - @opened="() => resolvedOpened(index)" + @closed="withSyncOpenDynamicModals(() => _vfm.resolvedClosed?.(index))" + @opened="() => _vfm.resolvedOpened?.(index)" >