|
|
@@ -26,7 +26,7 @@ const FollowPage: React.FC = () => {
|
|
|
// 从URL获取关注类型(following/followers)和用户ID
|
|
|
const searchParams = new URLSearchParams(location.search);
|
|
|
const type = (searchParams.get('type') || 'following') as FollowType;
|
|
|
- const userId = searchParams.get('userId') || user?.id?.toString();
|
|
|
+ const userId = Number(searchParams.get('userId')) || user?.id;
|
|
|
|
|
|
// 获取关注列表或粉丝列表
|
|
|
const fetchFollowList = async () => {
|
|
|
@@ -37,11 +37,13 @@ const FollowPage: React.FC = () => {
|
|
|
|
|
|
let response;
|
|
|
if (type === 'following') {
|
|
|
- response = await userClient[userId].following.$get({
|
|
|
+ response = await userClient[':id'].following.$get({
|
|
|
+ param: { id: userId },
|
|
|
query: { page: currentPage, pageSize }
|
|
|
});
|
|
|
} else {
|
|
|
- response = await userClient[userId].followers.$get({
|
|
|
+ response = await userClient[':id'].followers.$get({
|
|
|
+ param: { id: userId },
|
|
|
query: { page: currentPage, pageSize }
|
|
|
});
|
|
|
}
|
|
|
@@ -65,11 +67,13 @@ const FollowPage: React.FC = () => {
|
|
|
try {
|
|
|
if (isFollowing) {
|
|
|
// 取消关注
|
|
|
- await userClient[user.id].follow[targetUserId].$delete();
|
|
|
+ await userClient[':id'].follow.$delete({
|
|
|
+ param: { id: targetUserId}
|
|
|
+ });
|
|
|
} else {
|
|
|
// 关注用户
|
|
|
- await userClient[user.id].follow.$post({
|
|
|
- json: { followingId: targetUserId }
|
|
|
+ await userClient[':id'].follow.$post({
|
|
|
+ param: { id: targetUserId}
|
|
|
});
|
|
|
}
|
|
|
|