UserAvatar.vue 819 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <template>
  2. <div class="change-avatar">
  3. <CropperAvatar
  4. :value="avatar"
  5. :showBtn="false"
  6. @change="handelUpload"
  7. :btnProps="{ preIcon: 'ant-design:cloud-upload-outlined' }"
  8. width="120px"
  9. />
  10. </div>
  11. </template>
  12. <script setup lang="ts">
  13. import { computed } from 'vue'
  14. import { propTypes } from '@/utils/propTypes'
  15. import { CropperAvatar } from '@/components/Cropper'
  16. import { uploadAvatarApi } from '@/api/system/user/profile'
  17. const props = defineProps({
  18. img: propTypes.string.def('')
  19. })
  20. const avatar = computed(() => {
  21. return props.img
  22. })
  23. const handelUpload = async ({ data }) => {
  24. await uploadAvatarApi({ avatarFile: data })
  25. }
  26. </script>
  27. <style scoped lang="scss">
  28. .change-avatar {
  29. img {
  30. display: block;
  31. margin-bottom: 15px;
  32. border-radius: 50%;
  33. }
  34. }
  35. </style>