This commit is contained in:
2026-06-13 07:33:46 +08:00
parent e2da13bc5c
commit 24017e7454
40 changed files with 3135 additions and 108 deletions
+12
View File
@@ -11,6 +11,18 @@ export const chatApi = {
getConversationDetail: (id: string) => api.get(`/conversations/${id}`),
updateGroup: (id: string, data: { name?: string; description?: string }) =>
api.put(`/conversations/${id}`, data),
addMembers: (convId: string, userIds: string[]) =>
api.post(`/conversations/${convId}/members`, { user_ids: userIds }),
removeMember: (convId: string, userId: string) =>
api.delete(`/conversations/${convId}/members/${userId}`),
leaveGroup: (convId: string) =>
api.post(`/conversations/${convId}/leave`),
getMessages: (conversationId: string, before?: string, limit = 50) => {
const params: Record<string, any> = { limit }
if (before) params.before = before
+6
View File
@@ -8,12 +8,18 @@ export const friendsApi = {
sendRequest: (toUserId: string, message?: string) =>
api.post('/friends/request', { to_user_id: toUserId, message }),
addDirect: (toUserId: string) =>
api.post('/friends/add-direct', { to_user_id: toUserId }),
acceptRequest: (requestId: string) =>
api.put(`/friends/request/${requestId}/accept`),
rejectRequest: (requestId: string) =>
api.put(`/friends/request/${requestId}/reject`),
updateRemark: (friendUserId: string, remark: string | null) =>
api.put(`/friends/${friendUserId}/remark`, { remark }),
removeFriend: (friendId: string) =>
api.delete(`/friends/${friendId}`),
}
+30
View File
@@ -0,0 +1,30 @@
import api from './client'
export const momentsApi = {
getFeed: (cursor?: string, limit = 20) =>
api.get('/moments/', { params: { cursor, limit } }),
createMoment: (data: { content: string; images?: string[]; visibility?: string }) =>
api.post('/moments/', data),
deleteMoment: (id: string) =>
api.delete(`/moments/${id}`),
toggleLike: (id: string) =>
api.post(`/moments/${id}/like`),
getComments: (id: string) =>
api.get(`/moments/${id}/comments`),
addComment: (momentId: string, content: string, replyToId?: string) =>
api.post(`/moments/${momentId}/comments`, {
content,
reply_to_id: replyToId || null,
}),
deleteComment: (momentId: string, commentId: string) =>
api.delete(`/moments/${momentId}/comments/${commentId}`),
getUserMoments: (userId: string, cursor?: string) =>
api.get(`/moments/user/${userId}`, { params: { cursor } }),
}