From cc1e292ad3b031fa17a7b0ef8a67e2ace31cf556 Mon Sep 17 00:00:00 2001 From: 107 <107@DESKTOP-UP8U7M2> Date: Fri, 23 May 2025 10:24:43 +0700 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=20=D0=BD=D0=B0=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=B5=D0=BA=20=D0=BF=D1=80=D0=BE=D1=84=D0=B8?= =?UTF-8?q?=D0=BB=D1=8F=20=D1=81=20=D1=84=D0=BE=D1=82=D0=BA=D0=B0=D0=BC?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/ProfileView.vue | 49 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/src/views/ProfileView.vue b/src/views/ProfileView.vue index a5d630a..bade559 100644 --- a/src/views/ProfileView.vue +++ b/src/views/ProfileView.vue @@ -399,12 +399,29 @@ const fetchProfileDataLocal = async () => { }; const setAsMainPhoto = async (photoId) => { + if (!photoId) { + photoActionError.value = 'Неверный ID фотографии'; + return; + } + photoActionLoading.value = true; clearMessages(); try { + console.log('[ProfileView] Установка главного фото, ID:', photoId); const response = await api.setMainPhoto(photoId); + console.log('[ProfileView] Ответ сервера:', response.data); + + // Обновляем локальные данные сразу для быстрого отклика + if (profileData.value && profileData.value.photos) { + profileData.value.photos.forEach(photo => { + photo.isProfilePhoto = photo._id === photoId; + }); + } + + // Затем получаем актуальные данные с сервера await fetchUser(); + photoActionSuccess.value = response.data.message || 'Главное фото обновлено.'; // Автоматически скрываем сообщение через 3 секунды @@ -431,14 +448,29 @@ const closeDeleteModal = () => { }; const executeDeletePhoto = async () => { - if (!photoToDeleteId.value) return; + if (!photoToDeleteId.value) { + photoActionError.value = 'Неверный ID фотографии'; + return; + } photoActionLoading.value = true; clearMessages(); try { + console.log('[ProfileView] Удаление фото, ID:', photoToDeleteId.value); const response = await api.deletePhoto(photoToDeleteId.value); + console.log('[ProfileView] Ответ сервера:', response.data); + + // Обновляем локальные данные сразу для быстрого отклика + if (profileData.value && profileData.value.photos) { + profileData.value.photos = profileData.value.photos.filter( + photo => photo._id !== photoToDeleteId.value + ); + } + + // Затем получаем актуальные данные с сервера await fetchUser(); + photoActionSuccess.value = response.data.message || 'Фотография удалена.'; closeDeleteModal(); @@ -578,6 +610,16 @@ onMounted(async () => { .action-btn.small { padding: 0.5rem 1rem; font-size: 0.8rem; + min-width: 40px; + height: 40px; + border-radius: 50px; + display: flex; + align-items: center; + justify-content: center; +} + +.action-btn.small i { + font-size: 1rem; } .action-btn:disabled { @@ -955,8 +997,11 @@ onMounted(async () => { right: 10px; display: flex; gap: 0.5rem; - opacity: 0; + opacity: 1; transition: opacity 0.3s ease; + background: rgba(0, 0, 0, 0.7); + padding: 0.5rem; + border-radius: 10px; } .photo-item:hover .photo-actions {