perf: 优化账号设置-头像上传功能

This commit is contained in:
shuTwT 2024-04-19 10:52:39 +08:00 committed by GitHub
parent d203222acf
commit ada3e80c7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,7 +13,7 @@ defineOptions({
}); });
const imgSrc = ref(""); const imgSrc = ref("");
const cropperInfo = ref(); const cropperBlob = ref();
const cropRef = ref(); const cropRef = ref();
const uploadRef = ref(); const uploadRef = ref();
const isShow = ref(false); const isShow = ref(false);
@ -66,11 +66,11 @@ const handleClose = () => {
isShow.value = false; isShow.value = false;
}; };
const onCropper = info => (cropperInfo.value = info); const onCropper = ({ blob }) => (cropperBlob.value = blob);
const handleSubmitImage = () => { const handleSubmitImage = () => {
const formData = createFormData({ const formData = createFormData({
files: new File([cropperInfo.value], "avatar") files: new File([cropperBlob.value], "avatar")
}); });
formUpload(formData) formUpload(formData)
.then(({ success, data }) => { .then(({ success, data }) => {