mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
ui: add error feedback for avatar upload
This commit is contained in:
1 file changed
+16
-12
@@ -52,18 +52,22 @@ export default new NamedPage('home_account', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
$confirm.on('click', async () => {
|
$confirm.on('click', async () => {
|
||||||
if ($type.val() === 'upload') {
|
try {
|
||||||
const formData = new FormData();
|
if ($type.val() === 'upload') {
|
||||||
formData.append('file', $file[0].files[0]);
|
const formData = new FormData();
|
||||||
await request.postFile('/home/avatar', formData);
|
formData.append('file', $file[0].files[0]);
|
||||||
Notification.success(i18n('Upload success.'));
|
await request.postFile('/home/avatar', formData);
|
||||||
} else {
|
Notification.success(i18n('Upload success.'));
|
||||||
await request.post('/home/avatar', {
|
} else {
|
||||||
avatar: `${$type.val()}:${$text.val()}`,
|
await request.post('/home/avatar', {
|
||||||
});
|
avatar: `${$type.val()}:${$text.val()}`,
|
||||||
Notification.success(i18n('Updated.'));
|
});
|
||||||
|
Notification.success(i18n('Updated.'));
|
||||||
|
}
|
||||||
|
await delay(800);
|
||||||
|
window.location.reload();
|
||||||
|
} catch (e) {
|
||||||
|
Notification.error(e.message);
|
||||||
}
|
}
|
||||||
await delay(800);
|
|
||||||
window.location.reload();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user