Update user.js
This commit is contained in:
1 parent
7170add911
commit
d0df10df7f
1 file changed
+3
-1
+3
-1
@@ -7,6 +7,7 @@ async function renderUserProfile(username) {
|
||||
container.innerHTML = '<div style="text-align:center;color:#94a3b8;padding:40px 0;">加载中...</div>';
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user