diff --git a/js/user.js b/js/user.js
index 1b7ea5e..5a54008 100644
--- a/js/user.js
+++ b/js/user.js
@@ -7,6 +7,7 @@ async function renderUserProfile(username) {
container.innerHTML = '
加载中...
';
try {
+ // 1. 获取用户信息(通过 username 参数)
const users = await apiFetch('/users?username=' + encodeURIComponent(username));
const user = users && users.length > 0 ? users[0] : null;
@@ -17,6 +18,7 @@ async function renderUserProfile(username) {
document.getElementById('userPageTitle').textContent = '👤 ' + user.username;
+ // 2. 获取该用户的帖子(通过 user_id 筛选)
const posts = await apiFetch('/posts?user_id=' + user.id);
const avatar = user.avatar_url || 'https://ui-avatars.com/api/?name=' + encodeURIComponent(user.username) + '&background=6366f1&color=fff&size=128';
@@ -69,4 +71,4 @@ function showUserPage(username) {
el.style.animation = '';
currentPage = 'user';
renderUserProfile(username);
-}
\ No newline at end of file
+}