修改了用户头像的规则
parent
ce855a378f
commit
afb20d3ae0
|
|
@ -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 (
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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 (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue