Chore: 处理了Vben封装的Drawer,Modal组件的一些类型错误
parent
65800edb88
commit
d00d31d739
|
@ -133,7 +133,7 @@ function handleOk() {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<Drawer :root-class-name="prefixCls" v-bind="getBindValues" @close="onClose">
|
||||
<Drawer v-bind="getBindValues" @close="onClose">
|
||||
<template v-if="!$slots.title" #title>
|
||||
<DrawerHeader
|
||||
:title="getMergeProps.title as any" :is-detail="isDetail" :show-detail-back="showDetailBack"
|
||||
|
|
|
@ -3,7 +3,7 @@ import type { CSSProperties, ComputedRef, VNodeChild } from 'vue'
|
|||
import type { ScrollContainerOptions } from '@/components/Container'
|
||||
|
||||
export interface DrawerInstance {
|
||||
setDrawerProps: (props: Partial<DrawerProps> | boolean) => void
|
||||
setDrawerProps: (props: Partial<DrawerProps>) => void
|
||||
emitOpen?: (open: boolean, uid: number) => void
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ export interface ReturnMethods extends DrawerInstance {
|
|||
getOpen?: ComputedRef<boolean>
|
||||
}
|
||||
|
||||
export type RegisterFn = (drawerInstance: DrawerInstance, uuid?: string) => void
|
||||
export type RegisterFn = (drawerInstance: DrawerInstance, uuid: number) => void
|
||||
|
||||
export interface ReturnInnerMethods extends DrawerInstance {
|
||||
closeDrawer: () => void
|
||||
|
@ -100,7 +100,7 @@ export interface DrawerProps extends DrawerFooterProps {
|
|||
* @default 'body'
|
||||
* @type any ( HTMLElement| () => HTMLElement | string)
|
||||
*/
|
||||
getContainer?: () => HTMLElement | string
|
||||
getContainer?: string | false | HTMLElement | (() => HTMLElement)
|
||||
|
||||
/**
|
||||
* Whether to show mask or not.
|
||||
|
|
|
@ -19,9 +19,9 @@ export function useDrawer(): UseDrawerReturnType {
|
|||
|
||||
const drawer = ref<DrawerInstance | null>(null)
|
||||
const loaded = ref<Nullable<boolean>>(false)
|
||||
const uid = ref<string>('')
|
||||
const uid = ref<number>(0)
|
||||
|
||||
function register(drawerInstance: DrawerInstance, uuid: string) {
|
||||
function register(drawerInstance: DrawerInstance, uuid: number) {
|
||||
isProdMode()
|
||||
&& tryOnUnmounted(() => {
|
||||
drawer.value = null
|
||||
|
@ -50,7 +50,7 @@ export function useDrawer(): UseDrawerReturnType {
|
|||
}
|
||||
|
||||
const methods: ReturnMethods = {
|
||||
setDrawerProps: (props: Partial<DrawerProps>): void => {
|
||||
setDrawerProps: (props: Partial<DrawerProps>) => {
|
||||
getInstance()?.setDrawerProps(props)
|
||||
},
|
||||
|
||||
|
@ -85,7 +85,7 @@ export function useDrawer(): UseDrawerReturnType {
|
|||
export function useDrawerInner(callbackFn?: Fn): UseDrawerInnerReturnType {
|
||||
const drawerInstanceRef = ref<Nullable<DrawerInstance>>(null)
|
||||
const currentInstance = getCurrentInstance()
|
||||
const uidRef = ref<string>('')
|
||||
const uidRef = ref<number>(0)
|
||||
|
||||
if (!getCurrentInstance())
|
||||
throw new Error('useDrawerInner() can only be used inside setup() or functional components!')
|
||||
|
@ -99,7 +99,7 @@ export function useDrawerInner(callbackFn?: Fn): UseDrawerInnerReturnType {
|
|||
return instance
|
||||
}
|
||||
|
||||
const register = (modalInstance: DrawerInstance, uuid: string) => {
|
||||
const register = (modalInstance: DrawerInstance, uuid: number) => {
|
||||
isProdMode()
|
||||
&& tryOnUnmounted(() => {
|
||||
drawerInstanceRef.value = null
|
||||
|
|
|
@ -30,7 +30,7 @@ let realHeight = 0
|
|||
|
||||
const stopElResizeFn: Fn = () => {}
|
||||
|
||||
useWindowSizeFn(setModalHeight.bind(false))
|
||||
useWindowSizeFn(setModalHeight.bind(null))
|
||||
|
||||
useMutationObserver(
|
||||
spinRef,
|
||||
|
|
|
@ -16,9 +16,9 @@ const openData = reactive<{ [key: number]: boolean }>({})
|
|||
export function useModal(): UseModalReturnType {
|
||||
const modal = ref<Nullable<ModalMethods>>(null)
|
||||
const loaded = ref<Nullable<boolean>>(false)
|
||||
const uid = ref<string>('')
|
||||
const uid = ref<number>(0)
|
||||
|
||||
function register(modalMethod: ModalMethods, uuid: string) {
|
||||
function register(modalMethod: ModalMethods, uuid: number) {
|
||||
if (!getCurrentInstance())
|
||||
throw new Error('useModal() can only be used inside setup() or functional components!')
|
||||
|
||||
|
@ -88,7 +88,7 @@ export function useModal(): UseModalReturnType {
|
|||
export function useModalInner(callbackFn?: Fn): UseModalInnerReturnType {
|
||||
const modalInstanceRef = ref<Nullable<ModalMethods>>(null)
|
||||
const currentInstance = getCurrentInstance()
|
||||
const uidRef = ref<string>('')
|
||||
const uidRef = ref<number>(0)
|
||||
|
||||
const getInstance = () => {
|
||||
const instance = unref(modalInstanceRef)
|
||||
|
@ -98,7 +98,7 @@ export function useModalInner(callbackFn?: Fn): UseModalInnerReturnType {
|
|||
return instance
|
||||
}
|
||||
|
||||
const register = (modalInstance: ModalMethods, uuid: string) => {
|
||||
const register = (modalInstance: ModalMethods, uuid: number) => {
|
||||
isProdMode()
|
||||
&& tryOnUnmounted(() => {
|
||||
modalInstanceRef.value = null
|
||||
|
|
|
@ -10,7 +10,7 @@ export interface ModalMethods {
|
|||
redoModalHeight?: () => void
|
||||
}
|
||||
|
||||
export type RegisterFn = (modalMethods: ModalMethods, uuid?: string) => void
|
||||
export type RegisterFn = (modalMethods: ModalMethods, uuid: number) => void
|
||||
|
||||
export interface ReturnMethods extends ModalMethods {
|
||||
openModal: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void
|
||||
|
|
Loading…
Reference in New Issue