feat: port user profile feature from upstream

- GET /api/users?username= filter (admin)
- GET /api/posts?user_id= filter
- Add UserProfile page (profile card + user's posts), reachable via ?user=<username>
- Clickable usernames on feed, post detail, replies
This commit is contained in:
lezi-fun committed 2026-08-09 18:30:49 +08:00
1 parent e6ba5507ae
commit 5ef8d4b1ff
9 files changed
+166 -17

No files matched your search

+6 -1
View File
@@ -48,7 +48,11 @@ export const API = {
getMe() { return apiFetch('/auth/me'); },
// 帖子
getPosts(sort) { return apiFetch('/posts?sort=' + (sort || 'latest')); },
getPosts(sort, userId) {
let q = '/posts?sort=' + (sort || 'latest');
if (userId) q += '&user_id=' + userId;
return apiFetch(q);
},
getPost(postId) { return apiFetch('/posts/' + postId); },
createPost(title, content, images) {
return apiFetch('/posts', { method: 'POST', body: JSON.stringify({ title, content, images: images || [] }) });
@@ -64,6 +68,7 @@ export const API = {
// 用户管理
getUsers() { return apiFetch('/users'); },
getUsersByUsername(username) { return apiFetch('/users?username=' + encodeURIComponent(username)); },
updateUserRole(userId, role) {
return apiFetch('/users/' + userId + '/role', { method: 'PUT', body: JSON.stringify({ role }) });
},