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