diff --git a/src/app/ContestSite/ArenaPage.tsx b/src/app/ContestSite/ArenaPage.tsx index 44f1c7c8e..006ef0516 100644 --- a/src/app/ContestSite/ArenaPage.tsx +++ b/src/app/ContestSite/ArenaPage.tsx @@ -185,11 +185,11 @@ const ArenaPage: React.FC = ({ mode, user }) => { const firstImage = imageFiles[0]; return getAvatarUrl(firstImage.Key); } else { - return "/UserOutlined.png"; + return `https://api.dicebear.com/9.x/thumbs/svg?scale=80&backgroundType=gradientLinear&seed=${userId}`; } } catch (error) { console.error("Failed to load avatar:", error); - return "/UserOutlined.png"; + return `https://api.dicebear.com/9.x/thumbs/svg?scale=80&backgroundType=gradientLinear&seed=${userId}`; } }; diff --git a/src/app/ShareSite/CoursePage/DiscussDrawer.tsx b/src/app/ShareSite/CoursePage/DiscussDrawer.tsx index 85dbf6335..5afee3b92 100644 --- a/src/app/ShareSite/CoursePage/DiscussDrawer.tsx +++ b/src/app/ShareSite/CoursePage/DiscussDrawer.tsx @@ -291,7 +291,7 @@ const DiscussDrawer: React.FC = ({ const imageFiles = files.filter((file) => /\.(jpe?g|png)$/i.test(file.Key), ); - let avatarUrl = "/UserOutlined.png"; + let avatarUrl = `https://api.dicebear.com/9.x/thumbs/svg?scale=80&backgroundType=gradientLinear&seed=${userId}`; if (imageFiles.length > 0) { const firstImage = imageFiles[0]; avatarUrl = await getAvatarUrl(firstImage.Key); @@ -302,7 +302,7 @@ const DiscussDrawer: React.FC = ({ return avatarUrl; } catch (error) { console.error("Failed to load avatar:", error); - return "/UserOutlined.png"; + return `https://api.dicebear.com/9.x/thumbs/svg?scale=80&backgroundType=gradientLinear&seed=${userId}`; } }; diff --git a/src/app/UserSite/ProfilePage.tsx b/src/app/UserSite/ProfilePage.tsx index 6be350b6f..949d5cf22 100644 --- a/src/app/UserSite/ProfilePage.tsx +++ b/src/app/UserSite/ProfilePage.tsx @@ -86,7 +86,7 @@ const ProfilePage: React.FC = ({ mode, user, setUser }) => { message.error("加载头像失败"); }); } else { - setImageUrl("/UserOutlined.png"); // 替换为实际的默认头像 URL + setImageUrl(`https://api.dicebear.com/9.x/thumbs/svg?scale=80&backgroundType=gradientLinear&seed=${user.uuid}`); // 替换为实际的默认头像 URL } }) .catch((error) => { diff --git a/src/app/index.tsx b/src/app/index.tsx index 8b55f2d76..3a2c0efa6 100644 --- a/src/app/index.tsx +++ b/src/app/index.tsx @@ -88,7 +88,7 @@ const App: React.FC = () => { const firstImage = imageFiles[0]; return getAvatarUrl(firstImage.Key); } else { - setImageUrl("/UserOutlined.png"); // 替换为默认头像 URL + setImageUrl(`https://api.dicebear.com/9.x/thumbs/svg?scale=80&backgroundType=gradientLinear&seed=${user.uuid}`); // 替换为默认头像 URL return null; } }) @@ -501,7 +501,7 @@ const App: React.FC = () => { const firstImage = imageFiles[0]; return getAvatarUrl(firstImage.Key); } else { - setImageUrl("/UserOutlined.png"); // 替换为默认头像 URL + setImageUrl(`https://api.dicebear.com/9.x/thumbs/svg?scale=80&backgroundType=gradientLinear&seed=${user.uuid}`); // 替换为默认头像 URL return null; } })