perf: enhance openModal and openDrawer

This commit is contained in:
vben
2020-11-05 22:40:30 +08:00
parent 94bf854dd9
commit b6d5e5c96f
6 changed files with 38 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
import type { ButtonProps } from 'ant-design-vue/types/button/button';
import type { ButtonProps } from 'ant-design-vue/lib/button/buttonTypes';
import type { CSSProperties, VNodeChild } from 'vue';
/**
* @description: 弹窗对外暴露的方法
@@ -9,7 +9,7 @@ export interface ModalMethods {
export type RegisterFn = (modalMethods: ModalMethods, uuid?: string) => void;
export interface ReturnMethods extends ModalMethods {
openModal: (props?: boolean) => void;
openModal: <T = any>(props?: boolean, data?: T) => void;
transferModalData: (data: any) => void;
}
export type UseModalReturnType = [RegisterFn, ReturnMethods];

View File

@@ -46,10 +46,13 @@ export function useModal(): UseModalReturnType {
getInstance().setModalProps(props);
},
openModal: (visible = true): void => {
openModal: <T = any>(visible = true, data?: T): void => {
getInstance().setModalProps({
visible: visible,
});
if (data) {
dataTransferRef[unref(uidRef)] = data;
}
},
transferModalData(val: any) {