Commit f1c0e0c52bb3e687e00d3779e39875858d0f407d

Authored by 无木
1 parent 735028c4

types: fix CropperAvatar props define

src/components/Cropper/src/CropperAvatar.vue
@@ -29,7 +29,16 @@ @@ -29,7 +29,16 @@
29 </div> 29 </div>
30 </template> 30 </template>
31 <script lang="ts"> 31 <script lang="ts">
32 - import { defineComponent, computed, CSSProperties, unref, ref, watchEffect, watch } from 'vue'; 32 + import {
  33 + defineComponent,
  34 + computed,
  35 + CSSProperties,
  36 + unref,
  37 + ref,
  38 + watchEffect,
  39 + watch,
  40 + PropType,
  41 + } from 'vue';
33 import CopperModal from './CopperModal.vue'; 42 import CopperModal from './CopperModal.vue';
34 import { useDesign } from '/@/hooks/web/useDesign'; 43 import { useDesign } from '/@/hooks/web/useDesign';
35 import { useModal } from '/@/components/Modal'; 44 import { useModal } from '/@/components/Modal';
@@ -42,7 +51,7 @@ @@ -42,7 +51,7 @@
42 width: { type: [String, Number], default: '200px' }, 51 width: { type: [String, Number], default: '200px' },
43 value: { type: String }, 52 value: { type: String },
44 showBtn: { type: Boolean, default: true }, 53 showBtn: { type: Boolean, default: true },
45 - btnProps: { type: Object as ButtonProps }, 54 + btnProps: { type: Object as PropType<ButtonProps> },
46 btnText: { type: String, default: '' }, 55 btnText: { type: String, default: '' },
47 uploadApi: { type: Function as PropType<({ file: Blob, name: string }) => Promise<void>> }, 56 uploadApi: { type: Function as PropType<({ file: Blob, name: string }) => Promise<void>> },
48 }; 57 };
@@ -52,10 +61,10 @@ @@ -52,10 +61,10 @@
52 components: { CopperModal, Icon }, 61 components: { CopperModal, Icon },
53 props, 62 props,
54 emits: ['update:value', 'change'], 63 emits: ['update:value', 'change'],
55 - setup(props, { emit }) { 64 + setup(props, { emit, expose }) {
56 const sourceValue = ref(props.value || ''); 65 const sourceValue = ref(props.value || '');
57 const { prefixCls } = useDesign('cropper-avatar'); 66 const { prefixCls } = useDesign('cropper-avatar');
58 - const [register, { openModal }] = useModal(); 67 + const [register, { openModal, closeModal }] = useModal();
59 const { createMessage } = useMessage(); 68 const { createMessage } = useMessage();
60 const { t } = useI18n(); 69 const { t } = useI18n();
61 70
@@ -72,7 +81,7 @@ @@ -72,7 +81,7 @@
72 ); 81 );
73 82
74 watchEffect(() => { 83 watchEffect(() => {
75 - sourceValue.value = props.value; 84 + sourceValue.value = props.value || '';
76 }); 85 });
77 86
78 watch( 87 watch(
@@ -88,6 +97,8 @@ @@ -88,6 +97,8 @@
88 createMessage.success(t('component.cropper.uploadSuccess')); 97 createMessage.success(t('component.cropper.uploadSuccess'));
89 } 98 }
90 99
  100 + expose({ openModal: openModal.bind(null, true), closeModal });
  101 +
91 return { 102 return {
92 t, 103 t,
93 prefixCls, 104 prefixCls,