modified: begushiybashkir/bbvue/src/components/AvatarUpload.vue
modified: begushiybashkir/bbvue/src/stores/auth.js modified: serv_nginx/api_bb/.env modified: serv_nginx/api_bb/internal/config/config.go modified: serv_nginx/api_bb/internal/models/user.go modified: serv_nginx/api_bb/internal/routes/routes.go modified: serv_nginx/nginx/nginx-ssl.conf some for get photo from api_bb
This commit is contained in:
@@ -12,13 +12,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input
|
<input ref="fileInput" type="file" accept="image/jpeg,image/png,image/gif" @change="handleFileSelect"
|
||||||
ref="fileInput"
|
style="display: none;">
|
||||||
type="file"
|
|
||||||
accept="image/jpeg,image/png,image/gif"
|
|
||||||
@change="handleFileSelect"
|
|
||||||
style="display: none;"
|
|
||||||
>
|
|
||||||
|
|
||||||
<div v-if="uploading" class="upload-progress">
|
<div v-if="uploading" class="upload-progress">
|
||||||
Загрузка...
|
Загрузка...
|
||||||
@@ -63,9 +58,14 @@ export default {
|
|||||||
user: {
|
user: {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
handler(newUser) {
|
handler(newUser) {
|
||||||
|
console.log('User data:', newUser)
|
||||||
if (newUser?.avatar) {
|
if (newUser?.avatar) {
|
||||||
this.previewUrl = this.getFullAvatarUrl(newUser.avatar)
|
console.log('Avatar path:', newUser.avatar)
|
||||||
|
const fullUrl = this.getFullAvatarUrl(newUser.avatar)
|
||||||
|
console.log('Full avatar URL:', fullUrl)
|
||||||
|
this.previewUrl = fullUrl
|
||||||
} else {
|
} else {
|
||||||
|
console.log('No avatar found')
|
||||||
this.previewUrl = null
|
this.previewUrl = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,8 +74,22 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
getFullAvatarUrl(avatarPath) {
|
getFullAvatarUrl(avatarPath) {
|
||||||
if (!avatarPath) return null
|
if (!avatarPath) return null
|
||||||
|
|
||||||
|
// Если путь уже полный URL
|
||||||
if (avatarPath.startsWith('http')) return avatarPath
|
if (avatarPath.startsWith('http')) return avatarPath
|
||||||
|
|
||||||
|
// Если путь начинается с /uploads
|
||||||
|
if (avatarPath.startsWith('/uploads/')) {
|
||||||
return `${import.meta.env.VITE_API_BASE_URL}${avatarPath}`
|
return `${import.meta.env.VITE_API_BASE_URL}${avatarPath}`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Если путь относительный (avatars/filename.jpg)
|
||||||
|
if (avatarPath.startsWith('avatars/')) {
|
||||||
|
return `${import.meta.env.VITE_API_BASE_URL}/uploads/${avatarPath}`
|
||||||
|
}
|
||||||
|
|
||||||
|
// По умолчанию
|
||||||
|
return `${import.meta.env.VITE_API_BASE_URL}/uploads/${avatarPath}`
|
||||||
},
|
},
|
||||||
|
|
||||||
triggerFileInput() {
|
triggerFileInput() {
|
||||||
|
|||||||
@@ -13,3 +13,4 @@ ENVIRONMENT=development
|
|||||||
|
|
||||||
# app
|
# app
|
||||||
REST_API_VERSION=1.0.0
|
REST_API_VERSION=1.0.0
|
||||||
|
VITE_API_BASE_URL=https://begushiybashkir.ru
|
||||||
@@ -12,6 +12,7 @@ type Config struct {
|
|||||||
Port string
|
Port string
|
||||||
DatabaseURL string
|
DatabaseURL string
|
||||||
JWTSecret string
|
JWTSecret string
|
||||||
|
StaticURL string `env:"STATIC_URL" envDefault:"http://localhost:8080"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func Load() *Config {
|
func Load() *Config {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ type UserUpdate struct {
|
|||||||
ID uint `json:"id"`
|
ID uint `json:"id"`
|
||||||
FirstName string `json:"first_name"`
|
FirstName string `json:"first_name"`
|
||||||
LastName string `json:"last_name"`
|
LastName string `json:"last_name"`
|
||||||
Avatar string `json:"avatar"` // Добавить поле аватара
|
Avatar string `json:"avatar"`
|
||||||
Phone string `json:"phone"`
|
Phone string `json:"phone"`
|
||||||
Experience string `json:"experience"`
|
Experience string `json:"experience"`
|
||||||
Goals string `json:"goals"`
|
Goals string `json:"goals"`
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ func SetupRouter(db *gorm.DB, config *config.Config) http.Handler {
|
|||||||
r.Use(m)
|
r.Use(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Serve static files (avatars) - ДОБАВЬТЕ ЭТО
|
||||||
|
r.Handle("/uploads/*", http.StripPrefix("/uploads/",
|
||||||
|
http.FileServer(http.Dir("/app/uploads"))))
|
||||||
|
|
||||||
// Initialize repositories
|
// Initialize repositories
|
||||||
userRepo := repository.NewUserRepository(db)
|
userRepo := repository.NewUserRepository(db)
|
||||||
newsRepo := repository.NewNewsRepository(db)
|
newsRepo := repository.NewNewsRepository(db)
|
||||||
|
|||||||
@@ -134,4 +134,11 @@ server {
|
|||||||
proxy_read_timeout 600;
|
proxy_read_timeout 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
location /uploads/ {
|
||||||
|
alias /app/uploads/;
|
||||||
|
expires 1y;
|
||||||
|
add_header Cache-Control "public, immutable";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user