change getUrlAvatar path

This commit is contained in:
2025-10-14 22:22:31 +05:00
parent a5548178da
commit fe8616a032
32 changed files with 272 additions and 200 deletions
+78 -1
View File
@@ -2,4 +2,81 @@ Hosting by ValitovGaziz team on docker compose
create REST API on Golang 1.25.1
### zap logger внедрить
### zap logger внедрить
### Zagir Загир тренер
В общем, краткие выводы и мысли от Бэкъярда: попробовать стоит, интересный опыт. Главное знать когда остановиться, чтобы потом не пришлось восстанавливаться долго. Подметил для себя 4 момента:
- питаться надо привычной едой + соли различные, изотоник (регидрон), минералка, газировка. Горячее питание от организаторов хорошо заходило.
- круг надо бегать в темпе 6:20-6:50, чтобы во время отдыха успевать немного восстановиться, но при этом сильно не остывать. Быстрее 06:00 если бежать, то можешь закислиться.
- надо сразу психологию проработать, не ставить себе рамки и научиться не думать о дистанции и кругах, это реально выматывает.
- саппорт (поддержка) нужная вещь, чтобы и массаж делать, и питание приготовить. Я был 16 кругов один, поэтому не всегда успевал нормально все делать.
Отдельно хочу поблагодорить Загира, Сергея и Гаяза. Ваша помощь неоценима, пришли в самый тяжелый момент и как следует восстановили и смотивировали меня. Без вас планировал 15 (максимум 16) кругов сделать и сойти, так как мышцы уже реально "полнаелись". А так сделал 18 кругов и потенциально мог ещё 2 круга пробежать.
Ещё хочу поблагодарить Марата, который оказывал психологическую поддержку.
Парни, спасибо Вам большое.
Приехал домой, умылся, чай попил, теперь восстанавливаться🤝
----------------
🏃‍♂️🔥 «Белые Ночи – 3:34:33! Как Башкир сбросил час и покорил Питер» 🔥🏃‍♂️
21 ноября 2024 я написал Загиру: «Хочу из 4х».
5 июля 2025 я финишировал с 3:34:33 — и до сих пор не верю!
Это не просто личный рекорд. Это революция.
С 4:45 на Московском марафоне до 3:34 в Петербурге – за 8 месяцев.
Минус 71 минута – вот что значит правильный тренер, команда и… бурек!
---
Кто помогал лететь:
✊ Загир – тренер, который верил, даже когда я сам сомневался.
💪 Сергей – друг-соперник, который не давал расслабляться (спасибо за «гонку» на тренировках!).
👊 Вся семья «Бегущего Башкира» – без вас этот результат был бы просто цифрой.
-Секреты успеха:
✅ Образ «Бегущего Башкира»– бүрек + фирменная футболка = мощнейшая поддержка трибун. Казахи кричали «Жарайсың!», русские – «Давай, Башкир!», а я просто бежал и чувствовал силу предков которые передовались от их слов.
✅ Тактика: Первые 30 км – как часы, последние 12 – как воин.
✅ Питер – бежал по Дворцовому мосту, дышал невским ветром и ловил взгляды на стрелке Васильевского.
Финишные эмоции:
Когда увидел часы с 3:34 – понял: «Это не сон».
Загир сказал: «Ты мог бы и 3:30» – но я знаю, это только начало.
Следующая цель? Может, Казань или Москва – но точно с бүреком на голове!
### Благодарности:
📣 Зрителям – ваши крики «Башкир, давай!» грели даже под питерским дождём.
🏙️ Городу – ты сказочный, и твои мосты стали лучшими «подъёмами» на дистанции.
🏆 Себе – за то, что не сдался, когда было тяжело.
P.S. Теперь я знаю: «Невозможное» – это просто слово. Главное – найти свою команду и свой образ.
*(Прикрепляю фото с финиша – лицо счастья и бүрек, переживший все 42 км!)* 😍🎽
---
P.P.S. Загир, готовь новый план – теперь мы летим за 3:20! 🚀
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%------------
Отзывы
Загир Аминев Бег тренер, [13.10.2025 11:38]
Камила
Ғаяз, Айгөл, Ринат ҙуууур рәхмәт шундай байрам өсөн! Өҫтәл мул булды 👍🔥шулай ҡыҙыҡ тыуған көндәрегеҙ бер ваҡытта, тигәндәй! Ә хәҙер бер командалаһығыҙ! Гел шулай сағыу, мул, дәртле тормош алып барығыҙ! Һеҙ - Афариндар!!! 💪🤝🔥😎🔥
Загир Аминев Бег тренер, [13.10.2025 11:38]
ЗАрема
Мне тоже очень понравилось!
И азарт появился
На след год тоже надо участвовать обязательно.
Классное окружение, все заряженные.
Спасибо всем за эту атмосферу!
И благодарность тренеру, конечно ❤️
Спасибо большое за угощения вкусные именинникам.
Всех еще раз поздравляю 🥳
Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

Before

Width:  |  Height:  |  Size: 331 KiB

After

Width:  |  Height:  |  Size: 331 KiB

Before

Width:  |  Height:  |  Size: 262 KiB

After

Width:  |  Height:  |  Size: 262 KiB

Before

Width:  |  Height:  |  Size: 616 KiB

After

Width:  |  Height:  |  Size: 616 KiB

Before

Width:  |  Height:  |  Size: 253 KiB

After

Width:  |  Height:  |  Size: 253 KiB

Before

Width:  |  Height:  |  Size: 247 KiB

After

Width:  |  Height:  |  Size: 247 KiB

Before

Width:  |  Height:  |  Size: 128 KiB

After

Width:  |  Height:  |  Size: 128 KiB

Before

Width:  |  Height:  |  Size: 221 KiB

After

Width:  |  Height:  |  Size: 221 KiB

Before

Width:  |  Height:  |  Size: 430 KiB

After

Width:  |  Height:  |  Size: 430 KiB

Before

Width:  |  Height:  |  Size: 115 KiB

After

Width:  |  Height:  |  Size: 115 KiB

Before

Width:  |  Height:  |  Size: 243 KiB

After

Width:  |  Height:  |  Size: 243 KiB

Before

Width:  |  Height:  |  Size: 276 KiB

After

Width:  |  Height:  |  Size: 276 KiB

Before

Width:  |  Height:  |  Size: 220 KiB

After

Width:  |  Height:  |  Size: 220 KiB

Before

Width:  |  Height:  |  Size: 127 KiB

After

Width:  |  Height:  |  Size: 127 KiB

Before

Width:  |  Height:  |  Size: 511 KiB

After

Width:  |  Height:  |  Size: 511 KiB

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 134 KiB

Before

Width:  |  Height:  |  Size: 209 KiB

After

Width:  |  Height:  |  Size: 209 KiB

Before

Width:  |  Height:  |  Size: 308 KiB

After

Width:  |  Height:  |  Size: 308 KiB

Before

Width:  |  Height:  |  Size: 706 KiB

After

Width:  |  Height:  |  Size: 706 KiB

Before

Width:  |  Height:  |  Size: 205 KiB

After

Width:  |  Height:  |  Size: 205 KiB

Before

Width:  |  Height:  |  Size: 228 KiB

After

Width:  |  Height:  |  Size: 228 KiB

Before

Width:  |  Height:  |  Size: 228 KiB

After

Width:  |  Height:  |  Size: 228 KiB

Before

Width:  |  Height:  |  Size: 237 KiB

After

Width:  |  Height:  |  Size: 237 KiB

Before

Width:  |  Height:  |  Size: 235 KiB

After

Width:  |  Height:  |  Size: 235 KiB

Before

Width:  |  Height:  |  Size: 220 KiB

After

Width:  |  Height:  |  Size: 220 KiB

@@ -1,255 +1,234 @@
<!-- AvatarUpload.vue -->
<template>
<div class="avatar-upload">
<div class="avatar-preview">
<img
v-if="previewUrl"
:src="previewUrl"
alt="Аватар"
class="avatar-image"
@error="handleImageError"
/>
<div v-else class="avatar-placeholder">
👤
</div>
</div>
<div class="avatar-upload">
<div class="avatar-preview">
<img v-if="previewUrl" :src="previewUrl" alt="Аватар" class="avatar-image" @error="handleImageError" />
<div v-else class="avatar-placeholder">
👤
</div>
</div>
<div v-if="showActions" class="avatar-actions">
<label class="btn btn-small" :class="{ 'btn-disabled': uploading }">
{{ uploading ? 'Загрузка...' : '📷 Загрузить' }}
<input
type="file"
accept="image/*"
@change="handleFileSelect"
:disabled="uploading"
style="display: none;"
>
</label>
<button
v-if="previewUrl"
class="btn btn-small btn-danger"
@click="deleteAvatar"
:disabled="uploading"
>
🗑 Удалить
</button>
</div>
<div v-if="showActions" class="avatar-actions">
<label class="btn btn-small" :class="{ 'btn-disabled': uploading }">
{{ uploading ? 'Загрузка...' : '📷 Загрузить' }}
<input type="file" accept="image/*" @change="handleFileSelect" :disabled="uploading"
style="display: none;">
</label>
<div v-if="error" class="error-message">
{{ error }}
<button v-if="previewUrl" class="btn btn-small btn-danger" @click="deleteAvatar" :disabled="uploading">
🗑 Удалить
</button>
</div>
<div v-if="error" class="error-message">
{{ error }}
</div>
</div>
</div>
</template>
<script>
import { useAuthStore } from '../stores/auth'
export default {
name: 'AvatarUpload',
props: {
user: Object,
showActions: {
type: Boolean,
default: true
}
},
setup() {
const authStore = useAuthStore()
return { authStore }
},
data() {
return {
previewUrl: null,
uploading: false,
error: ''
}
},
watch: {
user: {
immediate: true,
handler(newUser) {
console.log('User data in AvatarUpload:', newUser)
if (newUser?.avatar) {
console.log('Avatar path:', newUser.avatar)
const fullUrl = this.getFullAvatarUrl(newUser.avatar)
console.log('Full avatar URL:', fullUrl)
this.previewUrl = fullUrl
} else {
console.log('No avatar found')
this.previewUrl = null
name: 'AvatarUpload',
props: {
user: Object,
showActions: {
type: Boolean,
default: true
}
}
}
},
methods: {
getFullAvatarUrl(avatarPath) {
if (!avatarPath) return null
console.log('Building URL for avatar path:', avatarPath)
// Если путь уже полный URL
if (avatarPath.startsWith('http')) {
return avatarPath
}
// Если путь начинается с /uploads
if (avatarPath.startsWith('/uploads/')) {
const fullUrl = `https://begushiybashkir.ru${avatarPath}`
console.log('Built URL with /uploads prefix:', fullUrl)
return fullUrl
}
// Если путь относительный
const fullUrl = `https://begushiybashkir.ru/uploads/${avatarPath}`
console.log('Built URL with relative path:', fullUrl)
return fullUrl
},
handleImageError(event) {
console.error('Error loading avatar image:', event)
this.previewUrl = null
setup() {
const authStore = useAuthStore()
return { authStore }
},
handleFileSelect(event) {
const file = event.target.files[0]
if (file) {
// Валидация файла
if (!file.type.startsWith('image/')) {
this.error = 'Пожалуйста, выберите файл изображения'
return
data() {
return {
previewUrl: null,
uploading: false,
error: ''
}
if (file.size > 5 * 1024 * 1024) { // 5MB
this.error = 'Размер файла не должен превышать 5MB'
return
}
// Создаем preview
const reader = new FileReader()
reader.onload = (e) => {
this.previewUrl = e.target.result
}
reader.readAsDataURL(file)
// Загружаем на сервер
this.uploadAvatar(file)
// Сбрасываем input
event.target.value = ''
}
},
async uploadAvatar(file) {
this.uploading = true
this.error = ''
try {
const result = await this.authStore.updateAvatar(file)
console.log('Upload result:', result)
if (result.success) {
this.$emit('avatar-updated', result.avatar)
} else {
this.error = result.error || 'Ошибка загрузки'
// Восстанавливаем старый preview
this.previewUrl = this.getFullAvatarUrl(this.user?.avatar)
watch: {
user: {
immediate: true,
handler(newUser) {
console.log('User data in AvatarUpload:', newUser)
if (newUser?.avatar) {
console.log('Avatar path:', newUser.avatar)
const fullUrl = this.getFullAvatarUrl(newUser.avatar)
console.log('Full avatar URL:', fullUrl)
this.previewUrl = fullUrl
} else {
console.log('No avatar found')
this.previewUrl = null
}
}
}
} catch (err) {
console.error('Upload error:', err)
this.error = 'Ошибка загрузки: ' + (err.message || 'Неизвестная ошибка')
this.previewUrl = this.getFullAvatarUrl(this.user?.avatar)
} finally {
this.uploading = false
}
},
methods: {
getFullAvatarUrl(avatarPath) {
if (!avatarPath) return null;
async deleteAvatar() {
this.uploading = true
this.error = ''
console.log('Building URL for avatar path:', avatarPath);
try {
const result = await this.authStore.deleteAvatar()
console.log('Delete result:', result)
if (result.success) {
this.previewUrl = null
this.$emit('avatar-updated', null)
} else {
this.error = result.error || 'Ошибка удаления'
if (avatarPath.startsWith('http')) {
return avatarPath;
}
// Извлекаем имя файла из пути
const filename = avatarPath.split('/').pop();
// Используем API эндпоинт вместо прямого доступа
const fullUrl = `https://begushiybashkir.ru/api/v1/user/avatar/${filename}`;
console.log('Built URL with API endpoint:', fullUrl);
return fullUrl;
},
handleImageError(event) {
console.error('Error loading avatar image:', event)
this.previewUrl = null
},
handleFileSelect(event) {
const file = event.target.files[0]
if (file) {
// Валидация файла
if (!file.type.startsWith('image/')) {
this.error = 'Пожалуйста, выберите файл изображения'
return
}
if (file.size > 5 * 1024 * 1024) { // 5MB
this.error = 'Размер файла не должен превышать 5MB'
return
}
// Создаем preview
const reader = new FileReader()
reader.onload = (e) => {
this.previewUrl = e.target.result
}
reader.readAsDataURL(file)
// Загружаем на сервер
this.uploadAvatar(file)
// Сбрасываем input
event.target.value = ''
}
},
async uploadAvatar(file) {
this.uploading = true
this.error = ''
try {
const result = await this.authStore.updateAvatar(file)
console.log('Upload result:', result)
if (result.success) {
this.$emit('avatar-updated', result.avatar)
} else {
this.error = result.error || 'Ошибка загрузки'
// Восстанавливаем старый preview
this.previewUrl = this.getFullAvatarUrl(this.user?.avatar)
}
} catch (err) {
console.error('Upload error:', err)
this.error = 'Ошибка загрузки: ' + (err.message || 'Неизвестная ошибка')
this.previewUrl = this.getFullAvatarUrl(this.user?.avatar)
} finally {
this.uploading = false
}
},
async deleteAvatar() {
this.uploading = true
this.error = ''
try {
const result = await this.authStore.deleteAvatar()
console.log('Delete result:', result)
if (result.success) {
this.previewUrl = null
this.$emit('avatar-updated', null)
} else {
this.error = result.error || 'Ошибка удаления'
}
} catch (err) {
console.error('Delete error:', err)
this.error = 'Ошибка удаления: ' + (err.message || 'Неизвестная ошибка')
} finally {
this.uploading = false
}
}
} catch (err) {
console.error('Delete error:', err)
this.error = 'Ошибка удаления: ' + (err.message || 'Неизвестная ошибка')
} finally {
this.uploading = false
}
}
}
}
</script>
<style scoped>
.avatar-upload {
text-align: center;
margin: 1rem 0;
text-align: center;
margin: 1rem 0;
}
.avatar-preview {
width: 120px;
height: 120px;
margin: 0 auto 1rem;
border-radius: 50%;
overflow: hidden;
border: 3px solid #e0e0e0;
background-color: #f5f5f5;
width: 120px;
height: 120px;
margin: 0 auto 1rem;
border-radius: 50%;
overflow: hidden;
border: 3px solid #e0e0e0;
background-color: #f5f5f5;
}
.avatar-image {
width: 100%;
height: 100%;
object-fit: cover;
width: 100%;
height: 100%;
object-fit: cover;
}
.avatar-placeholder {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 3rem;
background-color: #e0e0e0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 3rem;
background-color: #e0e0e0;
}
.avatar-actions {
display: flex;
gap: 0.5rem;
justify-content: center;
flex-wrap: wrap;
display: flex;
gap: 0.5rem;
justify-content: center;
flex-wrap: wrap;
}
.btn-small {
padding: 0.5rem 1rem;
font-size: 0.9rem;
padding: 0.5rem 1rem;
font-size: 0.9rem;
}
.btn-danger {
background-color: #dc3545;
color: white;
background-color: #dc3545;
color: white;
}
.btn-danger:hover:not(:disabled) {
background-color: #c82333;
background-color: #c82333;
}
.btn-disabled {
background-color: #ccc;
cursor: not-allowed;
background-color: #ccc;
cursor: not-allowed;
}
.error-message {
color: #dc3545;
font-size: 0.9rem;
margin-top: 0.5rem;
color: #dc3545;
font-size: 0.9rem;
margin-top: 0.5rem;
}
</style>
+16
View File
@@ -109,6 +109,22 @@ export const useAuthStore = defineStore('auth', () => {
}
const updateAvatar = async (avatarFile) => {
const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB
if (avatarFile.size > MAX_FILE_SIZE) {
return {
success: false,
error: 'Размер файла не должен превышать 5MB'
};
}
// ✅ ПРОВЕРКА ТИПА ФАЙЛА
const allowedTypes = ['image/jpeg', 'image/jpg', 'image/png', 'image/gif', 'image/webp'];
if (!allowedTypes.includes(avatarFile.type)) {
return {
success: false,
error: 'Допустимые форматы: JPEG, PNG, GIF, '
};
}
const formData = new FormData()
formData.append('avatar', avatarFile)