mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +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 () => {
|
||||
if ($type.val() === 'upload') {
|
||||
const formData = new FormData();
|
||||
formData.append('file', $file[0].files[0]);
|
||||
await request.postFile('/home/avatar', formData);
|
||||
Notification.success(i18n('Upload success.'));
|
||||
} else {
|
||||
await request.post('/home/avatar', {
|
||||
avatar: `${$type.val()}:${$text.val()}`,
|
||||
});
|
||||
Notification.success(i18n('Updated.'));
|
||||
try {
|
||||
if ($type.val() === 'upload') {
|
||||
const formData = new FormData();
|
||||
formData.append('file', $file[0].files[0]);
|
||||
await request.postFile('/home/avatar', formData);
|
||||
Notification.success(i18n('Upload success.'));
|
||||
} else {
|
||||
await request.post('/home/avatar', {
|
||||
avatar: `${$type.val()}:${$text.val()}`,
|
||||
});
|
||||
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