zn-admin-vue3-wcs/src/views/Profile/components/UserAvatar.vue
YunaiV 4404554cfc 1. 统一化代码
2. 增加 DocAlert 关联文档
2023-04-05 20:13:35 +08:00

39 lines
804 B
Vue

<template>
<div class="change-avatar">
<CropperAvatar
ref="cropperRef"
:value="avatar"
:showBtn="false"
@change="handelUpload"
:btnProps="{ preIcon: 'ant-design:cloud-upload-outlined' }"
width="120px"
/>
</div>
</template>
<script setup lang="ts">
import { propTypes } from '@/utils/propTypes'
import { uploadAvatar } from '@/api/system/user/profile'
const props = defineProps({
img: propTypes.string.def('')
})
const avatar = computed(() => {
return props.img
})
const cropperRef = ref()
const handelUpload = async ({ data }) => {
await uploadAvatar({ avatarFile: data })
cropperRef.value.close()
}
</script>
<style scoped lang="scss">
.change-avatar {
img {
display: block;
margin-bottom: 15px;
border-radius: 50%;
}
}
</style>