modified: begushiybashkir/bbvue/src/views/Profile.vue

set cool path for src img avatar but not laud becouse authorization
This commit is contained in:
2025-10-14 23:37:28 +05:00
parent fcccb34b86
commit 07e0178516
+25 -31
View File
@@ -9,20 +9,15 @@
<!-- Обновленная секция аватара --> <!-- Обновленная секция аватара -->
<div class="avatar-section"> <div class="avatar-section">
<div class="avatar-preview"> <div class="avatar-preview">
<img <img v-if="user.avatar" :src="avatarUrl" :alt="`Аватар ${user.firstName} ${user.lastName}`"
v-if="user.avatar" class="avatar-image" @error="handleAvatarError">
:src="avatarUrl"
:alt="`Аватар ${user.firstName} ${user.lastName}`"
class="avatar-image"
@error="handleAvatarError"
>
<div v-else class="avatar-placeholder"> <div v-else class="avatar-placeholder">
👤 👤
</div> </div>
</div> </div>
<AvatarUpload :user="user" @avatar-updated="onAvatarUpdated" /> <AvatarUpload :user="user" @avatar-updated="onAvatarUpdated" />
</div> </div>
<h2>{{ user.firstName }} {{ user.lastName }}</h2> <h2>{{ user.firstName }} {{ user.lastName }}</h2>
<p>Участник с {{ joinDate }}</p> <p>Участник с {{ joinDate }}</p>
<p class="user-email">{{ user.email }}</p> <p class="user-email">{{ user.email }}</p>
@@ -160,17 +155,13 @@ export default {
// Вычисляем полный URL аватара // Вычисляем полный URL аватара
avatarUrl() { avatarUrl() {
if (!this.user?.avatar) return null; if (!this.user?.avatar) return null;
// Если avatar уже содержит полный URL, возвращаем как есть
if (this.user.avatar.startsWith('http')) {
return this.user.avatar;
}
// Иначе формируем полный URL
const baseUrl = 'https://begushiybashkir.ru/api/v1/user';
alert(this.user.avatar) let filename = this.user.avatar.trim('/').split('/').pop();
return baseUrl + this.user.avatar;
// Иначе формируем полный URL
const baseUrl = 'https://begushiybashkir.ru/api/v1/user/avatars/';
return baseUrl + filename;
}, },
joinDate() { joinDate() {
if (!this.user?.createdAt) return 'января 2024'; if (!this.user?.createdAt) return 'января 2024';
@@ -211,13 +202,13 @@ export default {
await this.authStore.fetchProfile(); await this.authStore.fetchProfile();
console.log('Avatar updated, user data:', this.authStore.user); console.log('Avatar updated, user data:', this.authStore.user);
}, },
// Обработчик ошибки загрузки изображения // Обработчик ошибки загрузки изображения
handleAvatarError() { handleAvatarError() {
console.error('Ошибка загрузки аватара:', this.avatarUrl); console.error('Ошибка загрузки аватара:', this.avatarUrl);
this.avatarLoadError = true; this.avatarLoadError = true;
}, },
async loadUserData() { async loadUserData() {
this.authLoading = true; this.authLoading = true;
this.avatarLoadError = false; this.avatarLoadError = false;
@@ -230,7 +221,7 @@ export default {
this.authLoading = false; this.authLoading = false;
} }
}, },
async loadStats() { async loadStats() {
this.statsLoading = true; this.statsLoading = true;
try { try {
@@ -251,20 +242,20 @@ export default {
this.statsLoading = false; this.statsLoading = false;
} }
}, },
async refreshStats() { async refreshStats() {
await this.loadStats(); await this.loadStats();
}, },
async handleLogout() { async handleLogout() {
await this.authStore.logout(); await this.authStore.logout();
this.$router.push('/'); this.$router.push('/');
}, },
editProfile() { editProfile() {
this.$router.push('/profile/edit'); this.$router.push('/profile/edit');
}, },
viewDetailedStats() { viewDetailedStats() {
// TODO: Переход на страницу детальной статистики // TODO: Переход на страницу детальной статистики
alert('Функция в разработке'); alert('Функция в разработке');
@@ -343,12 +334,15 @@ export default {
font-size: 1.8rem; font-size: 1.8rem;
} }
.user-email, .user-phone { .user-email,
.user-phone {
color: #666; color: #666;
margin: 0.25rem 0; margin: 0.25rem 0;
} }
.profile-info, .profile-stats, .achievements-preview { .profile-info,
.profile-stats,
.achievements-preview {
background: white; background: white;
padding: 1.5rem; padding: 1.5rem;
border-radius: 15px; border-radius: 15px;
@@ -584,7 +578,7 @@ export default {
.page { .page {
padding: 1rem; padding: 1rem;
} }
.info-grid { .info-grid {
grid-template-columns: 1fr; grid-template-columns: 1fr;
} }
@@ -601,7 +595,7 @@ export default {
flex-direction: column; flex-direction: column;
gap: 0.5rem; gap: 0.5rem;
} }
.avatar-preview { .avatar-preview {
width: 120px; width: 120px;
height: 120px; height: 120px;
@@ -612,11 +606,11 @@ export default {
.stats-grid { .stats-grid {
grid-template-columns: 1fr; grid-template-columns: 1fr;
} }
.profile-header { .profile-header {
padding: 1.5rem; padding: 1.5rem;
} }
.profile-header h2 { .profile-header h2 {
font-size: 1.5rem; font-size: 1.5rem;
} }