From d0df10df7f5a8c339e0e602e3e7fabb71169f6cf Mon Sep 17 00:00:00 2001 From: Furrium Network Date: Sun, 9 Aug 2026 18:22:10 +0800 Subject: [PATCH] Update user.js --- js/user.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 +}