feat(member): 썸네일 교체/삭제 시 자산 자동 정리 추가
회원 아바타를 교체·삭제·탈퇴하는 흐름에서 이전 썸네일 파일과 메타데이터가 남지 않도록 공통 정리 로직을 연결했다. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,6 +4,7 @@ const savingProfile = ref(false)
|
||||
const savingPassword = ref(false)
|
||||
const deletingAccount = ref(false)
|
||||
const uploadingAvatar = ref(false)
|
||||
const removingAvatar = ref(false)
|
||||
const profileMessage = ref('')
|
||||
const passwordMessage = ref('')
|
||||
const deleteMessage = ref('')
|
||||
@@ -99,6 +100,31 @@ const saveProfile = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 썸네일을 제거한다.
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
const removeAvatar = async () => {
|
||||
if (removingAvatar.value) {
|
||||
return
|
||||
}
|
||||
|
||||
removingAvatar.value = true
|
||||
profileMessage.value = ''
|
||||
|
||||
try {
|
||||
await $fetch('/api/auth/avatar', {
|
||||
method: 'DELETE'
|
||||
})
|
||||
profileForm.avatarUrl = ''
|
||||
profileMessage.value = '썸네일이 제거되었습니다.'
|
||||
} catch (error) {
|
||||
profileMessage.value = error?.data?.message || '썸네일 제거에 실패했습니다.'
|
||||
} finally {
|
||||
removingAvatar.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 썸네일 파일을 업로드한다.
|
||||
* @param {Event} event - 파일 선택 이벤트
|
||||
@@ -231,6 +257,14 @@ onMounted(loadProfile)
|
||||
class="h-10 rounded-[8px] border border-[var(--site-line)] bg-transparent px-3 text-sm outline-none focus-visible:border-[var(--site-accent)]"
|
||||
placeholder="https://..."
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="w-fit rounded-[10px] border border-[var(--site-line)] px-3 py-1.5 text-xs site-muted transition-opacity hover:opacity-80 disabled:opacity-60"
|
||||
:disabled="removingAvatar"
|
||||
@click="removeAvatar"
|
||||
>
|
||||
{{ removingAvatar ? '제거 중...' : '썸네일 제거' }}
|
||||
</button>
|
||||
<label class="text-xs site-muted">썸네일 업로드</label>
|
||||
<input
|
||||
type="file"
|
||||
|
||||
Reference in New Issue
Block a user