From 749201996b62d52eb7d50cedcb25227e2b72b177 Mon Sep 17 00:00:00 2001 From: xingyu Date: Thu, 26 Oct 2023 11:06:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=8A=BD=E5=B1=89=E5=BC=B9=E6=A1=86=E6=BB=9A=E5=8A=A8=E6=9D=A1?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Drawer/src/BasicDrawer.vue | 41 ++++++++++++++--------- src/components/Drawer/src/typing.ts | 4 +-- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/components/Drawer/src/BasicDrawer.vue b/src/components/Drawer/src/BasicDrawer.vue index 80ca879..5440169 100644 --- a/src/components/Drawer/src/BasicDrawer.vue +++ b/src/components/Drawer/src/BasicDrawer.vue @@ -6,27 +6,28 @@ import type { DrawerInstance, DrawerProps } from './typing' import DrawerFooter from './components/DrawerFooter.vue' import DrawerHeader from './components/DrawerHeader.vue' import { basicProps } from './props' +import { useAttrs } from '@/hooks/core/useAttrs' import { useI18n } from '@/hooks/web/useI18n' +import { isFunction, isNumber } from '@/utils/is' import { deepMerge } from '@/utils' import { ScrollContainer } from '@/components/Container' -import { isFunction, isNumber } from '@/utils/is' import { useDesign } from '@/hooks/web/useDesign' -import { useAttrs } from '@/hooks/core/useAttrs' defineOptions({ inheritAttrs: false }) const props = defineProps(basicProps) -const emit = defineEmits(['openChange', 'ok', 'close', 'register']) + +const emit = defineEmits(['open-change', 'ok', 'close', 'register']) const openRef = ref(false) const attrs = useAttrs() -const propsRef = ref>>(null) +const propsRef = ref>(null) const { t } = useI18n() const { prefixVar, prefixCls } = useDesign('basic-drawer') const drawerInstance: DrawerInstance = { - setDrawerProps, + setDrawerProps: setDrawerProps as any, emitOpen: undefined, } @@ -34,8 +35,8 @@ const instance = getCurrentInstance() instance && emit('register', drawerInstance, instance.uid) -const getMergeProps = computed((): DrawerProps => { - return deepMerge(toRaw(props), unref(propsRef)) +const getMergeProps: any = computed((): DrawerProps => { + return deepMerge(toRaw(props), unref(propsRef)) as any }) const getProps = computed((): DrawerProps => { @@ -70,10 +71,12 @@ const getBindValues = computed((): DrawerProps => { // Custom implementation of the bottom button, const getFooterHeight = computed(() => { const { footerHeight, showFooter } = unref(getProps) - if (showFooter && footerHeight) - return isNumber(footerHeight) ? `${footerHeight}px` : `${footerHeight.replace('px', '')}px` - - return '0px' + if (showFooter && footerHeight) { + return isNumber(footerHeight) + ? `${footerHeight}px` + : `${footerHeight.replace('px', '')}px` + } + return `0px` }) const getScrollContentStyle = computed((): CSSProperties => { @@ -101,14 +104,14 @@ watch( () => openRef.value, (open) => { nextTick(() => { - emit('openChange', open) + emit('open-change', open) instance && drawerInstance.emitOpen?.(open, instance.uid) }) }, ) // Cancel event -async function onClose(e: Recordable) { +async function onClose(e) { const { closeFunc } = unref(getProps) emit('close', e) if (closeFunc && isFunction(closeFunc)) { @@ -133,10 +136,12 @@ function handleOk() {