Ben Lin
2024-11-08 3d2c48733b86a03fc2e5a1f12ac3667ab0863b80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Modal } from 'ant-design-vue';
import { defineComponent, toRefs, unref } from 'vue';
import { basicProps } from '../props';
import { useModalDragMove } from '../hooks/useModalDrag';
import { extendSlots } from '@/utils/helper/tsxHelper';
 
export default defineComponent({
  name: 'Modal',
  inheritAttrs: false,
  props: basicProps as any,
  emits: ['cancel'],
  setup(props, { slots, emit, attrs }) {
    const { open, draggable, destroyOnClose } = toRefs(props);
    useModalDragMove({
      open,
      destroyOnClose,
      draggable,
    });
 
    const onCancel = (e: Event) => {
      emit('cancel', e);
    };
 
    return () => {
      const propsData = { ...unref(attrs), ...props, onCancel } as Recordable;
      return <Modal {...propsData}>{extendSlots(slots)}</Modal>;
    };
  },
});