修改了用户头像的规则

main
mula.liu 2026-01-18 13:33:50 +08:00
parent ce855a378f
commit afb20d3ae0
4 changed files with 4 additions and 7 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -27,8 +27,7 @@ export function UserAuth({ user, onOpenAuth, onLogout, onNavigateToAdmin }: User
// Helper to get full avatar URL // Helper to get full avatar URL
const getAvatarUrl = () => { const getAvatarUrl = () => {
if (!user?.avatar_url) return null; if (!user?.avatar_url) return null;
const rootUrl = API_BASE_URL.replace('/api', ''); return `/upload/${user.avatar_url}`;
return `${rootUrl}/upload/${user.avatar_url}`;
}; };
return ( return (

View File

@ -66,8 +66,7 @@ export function AdminLayout() {
// Helper to get full avatar URL // Helper to get full avatar URL
const getAvatarUrl = () => { const getAvatarUrl = () => {
if (!user?.avatar_url) return null; if (!user?.avatar_url) return null;
const rootUrl = API_BASE_URL.replace('/api', ''); return `/upload/${user.avatar_url}`;
return `${rootUrl}/upload/${user.avatar_url}`;
}; };
// Load menus from backend // Load menus from backend

View File

@ -88,10 +88,9 @@ export function UserProfile() {
// Construct full avatar URL // Construct full avatar URL
const getAvatarUrl = () => { const getAvatarUrl = () => {
if (!userProfile?.avatar_url) return null; if (!userProfile?.avatar_url) return null;
// Use relative path to allow proxying (Vite/Nginx)
// The backend returns a relative path like "user/1/avatar/avatar.png" // The backend returns a relative path like "user/1/avatar/avatar.png"
// The upload directory is mounted at /upload return `/upload/${userProfile.avatar_url}?t=${new Date().getTime()}`;
const rootUrl = API_BASE_URL.replace('/api', '');
return `${rootUrl}/upload/${userProfile.avatar_url}?t=${new Date().getTime()}`;
}; };
return ( return (