TRM-coding | 29174c2 | 2025-06-18 23:56:51 +0800 | [diff] [blame] | 1 | import axios from 'axios'; |
22301008 | e25b4b0 | 2025-06-20 22:15:31 +0800 | [diff] [blame^] | 2 | import { getUserInfo } from '../utils/auth'; |
TRM-coding | 29174c2 | 2025-06-18 23:56:51 +0800 | [diff] [blame] | 3 | |
| 4 | const api = axios.create({ |
| 5 | baseURL: 'http://10.126.59.25:5715/api/', |
| 6 | withCredentials: true |
| 7 | }); |
| 8 | |
| 9 | // 用户相关API |
| 10 | export const getCurrentUser = () => api.get('/current-user'); |
| 11 | export const getUser = (userId) => api.get(`/user/${userId}`); |
| 12 | export const updateUser = (userId, data) => api.put(`/user/${userId}`, data); |
| 13 | |
| 14 | // 收藏相关API |
| 15 | export const getFavorites = (userId) => api.get(`/user/${userId}/favorites`); |
| 16 | |
| 17 | // 关注相关API |
22301008 | e25b4b0 | 2025-06-20 22:15:31 +0800 | [diff] [blame^] | 18 | export const followUser = (followeeId) => { |
| 19 | return api.post(`/follow/${followeeId}`); |
| 20 | }; |
| 21 | export const unfollowUser = (followeeId) => { |
| 22 | return api.delete(`/follow/${followeeId}`); |
| 23 | }; |
TRM-coding | 29174c2 | 2025-06-18 23:56:51 +0800 | [diff] [blame] | 24 | |
| 25 | // 帖子相关API |
| 26 | export const getUserPosts = (userId) => api.get(`/user/${userId}/posts`); |
| 27 | |
| 28 | // 关注列表API |
| 29 | export const getUserFollowing = (userId) => api.get(`/user/${userId}/following`); |
| 30 | |
| 31 | // 用户互动数据API |
| 32 | export const getUserInteractions = (userId) => api.get(`/user/${userId}/interactions`); |
| 33 | // 获取粉丝 |
| 34 | export const getUserFollowers = (userId) => api.get(`/user/${userId}/followers`); |
| 35 | |
| 36 | export default api; |