Commit f1c0e0c52bb3e687e00d3779e39875858d0f407d

Authored by 无木
1 parent 735028c4

types: fix CropperAvatar props define

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