From 00236c746b2f7d76ec61af6c3c1bc532a3bacde6 Mon Sep 17 00:00:00 2001 From: marzban-dev Date: Thu, 23 Apr 2026 16:08:52 +0330 Subject: [PATCH] Add default profile button --- .../profile/index/ProfilePictureModal.vue | 71 ++++++++++++------ frontend/public/img/default-avatar.jpeg | Bin 0 -> 2294 bytes 2 files changed, 46 insertions(+), 25 deletions(-) create mode 100644 frontend/public/img/default-avatar.jpeg diff --git a/frontend/components/profile/index/ProfilePictureModal.vue b/frontend/components/profile/index/ProfilePictureModal.vue index d9af18d..48eed3b 100644 --- a/frontend/components/profile/index/ProfilePictureModal.vue +++ b/frontend/components/profile/index/ProfilePictureModal.vue @@ -12,7 +12,7 @@ type Props = { }; type Emits = { - "update:modelValue": [value: File]; + "update:modelValue": [value: File | null]; "update:isShow": [value: boolean]; }; @@ -59,8 +59,7 @@ const { isPending: updateAccountIsPending } = useUpdateAccount(); // computed const currentProfile = computed({ - get: () => - !!modelValue.value ? URL.createObjectURL(modelValue.value) : null, + get: () => (!!modelValue.value ? URL.createObjectURL(modelValue.value) : null), set: (value: File) => emit("update:modelValue", value), }); @@ -81,6 +80,15 @@ onFileDialogChange((files: any) => { emit("update:modelValue", file); resetFileDialog(); }); + +const resetAvatarFile = async () => { + const response = await fetch("/img/default-avatar.jpeg"); + const blob = await response.blob(); + const file = new File([blob], "default-avatar.jpeg", { type: blob.type }); + + emit("update:modelValue", file); + resetFileDialog(); +};