From 61e8415f8b0fbdb37a23e08d2078f63899d07d49 Mon Sep 17 00:00:00 2001 From: valitovgaziz Date: Mon, 13 Oct 2025 04:43:38 +0500 Subject: [PATCH] modified: begushiybashkir/bbvue/src/components/AvatarUpload.vue modified: begushiybashkir/bbvue/src/stores/auth.js modified: begushiybashkir/bbvue/src/views/Profile.vue avatar fix --- .../bbvue/src/components/AvatarUpload.vue | 154 +++++++++++++++++- begushiybashkir/bbvue/src/stores/auth.js | 9 + begushiybashkir/bbvue/src/views/Profile.vue | 31 ++++ 3 files changed, 186 insertions(+), 8 deletions(-) diff --git a/begushiybashkir/bbvue/src/components/AvatarUpload.vue b/begushiybashkir/bbvue/src/components/AvatarUpload.vue index bbf0a02..026af23 100644 --- a/begushiybashkir/bbvue/src/components/AvatarUpload.vue +++ b/begushiybashkir/bbvue/src/components/AvatarUpload.vue @@ -1,4 +1,47 @@ + + \ No newline at end of file + + + \ No newline at end of file diff --git a/begushiybashkir/bbvue/src/stores/auth.js b/begushiybashkir/bbvue/src/stores/auth.js index 298df86..257c39b 100644 --- a/begushiybashkir/bbvue/src/stores/auth.js +++ b/begushiybashkir/bbvue/src/stores/auth.js @@ -113,12 +113,17 @@ export const useAuthStore = defineStore('auth', () => { formData.append('avatar', avatarFile) try { + loading.value = true + error.value = '' + const response = await apiClient.post('/user/avatar/upload', formData, { headers: { 'Content-Type': 'multipart/form-data' } }) + console.log('Avatar upload response:', response.data) + // Универсальная обработка ответа let result if (response.data.success !== undefined) { @@ -135,9 +140,13 @@ export const useAuthStore = defineStore('auth', () => { } else { return { success: false, error: result.error || result.message } } + } catch (error) { + console.error('Avatar upload error:', error) const result = handleApiError(error) return result + } finally { + loading.value = false } } diff --git a/begushiybashkir/bbvue/src/views/Profile.vue b/begushiybashkir/bbvue/src/views/Profile.vue index cd457ca..07f5233 100644 --- a/begushiybashkir/bbvue/src/views/Profile.vue +++ b/begushiybashkir/bbvue/src/views/Profile.vue @@ -237,6 +237,37 @@ export default {