diff --git a/unilife-frontend/src/api/auth.ts b/unilife-frontend/src/api/auth.ts index b83d684..f42f49c 100644 --- a/unilife-frontend/src/api/auth.ts +++ b/unilife-frontend/src/api/auth.ts @@ -50,4 +50,22 @@ export const uploadAvatar = (file: File) => { // 更新邮箱 export const updateEmail = (email: string, code: string) => { return api.put('/users/email', { email, code }) +} + +// 获取用户统计数据 +export const getUserStats = () => { + return api.get>('/users/stats') +} + +// 获取用户最近帖子 +export const getUserRecentPosts = (limit?: number) => { + const params = limit ? { limit } : {} + return api.get>('/users/recent-posts', { params }) } \ No newline at end of file diff --git a/unilife-frontend/src/api/forum.ts b/unilife-frontend/src/api/forum.ts index 282123d..3d6bc78 100644 --- a/unilife-frontend/src/api/forum.ts +++ b/unilife-frontend/src/api/forum.ts @@ -49,6 +49,67 @@ export const likePost = (id: number) => { return api.post>(`/posts/${id}/like`) } +// 获取用户的帖子列表 +export const getUserPosts = (userId: number, params?: { + page?: number + size?: number + sort?: string +}) => { + return api.get>(`/posts/user/${userId}`, { params }) +} + +// ==================== 评论管理 ==================== + +// 获取评论列表 +export const getComments = (postId: number) => { + return api.get + }> + }>>(`/comments/post/${postId}`) +} + +// 发表评论 +export const createComment = (data: { + postId: number + content: string + parentId?: number | null +}) => { + return api.post>('/comments', data) +} + +// 删除评论 +export const deleteComment = (id: number) => { + return api.delete>(`/comments/${id}`) +} + +// 点赞/取消点赞评论 +export const likeComment = (id: number) => { + return api.post>(`/comments/${id}/like`) +} + // 获取分类列表 export const getCategories = (params?: { status?: number }) => { return api.get
- + @@ -129,17 +129,17 @@
- -
+ +
- + {{ post.nickname?.charAt(0) }}
@@ -177,22 +177,39 @@
- + - 点赞 + {{ post.isLiked ? '已点赞' : '点赞' }}
-
+
发布第一个帖子
+ + +
+ +
@@ -207,21 +224,41 @@ > - + - - - + + - +
@@ -230,7 +267,7 @@ @@ -635,6 +781,18 @@ onMounted(() => { gap: 16px; } +/* 分页样式 */ +.pagination-section { + margin-top: 32px; + display: flex; + justify-content: center; + padding: 24px; + background: rgba(255, 255, 255, 0.8); + border-radius: 16px; + backdrop-filter: blur(20px); + border: 1px solid rgba(255, 255, 255, 0.2); +} + .stat-item { display: flex; align-items: center; diff --git a/unilife-frontend/src/views/forum/PostDetailView.vue b/unilife-frontend/src/views/forum/PostDetailView.vue index 9a3b14a..3312647 100644 --- a/unilife-frontend/src/views/forum/PostDetailView.vue +++ b/unilife-frontend/src/views/forum/PostDetailView.vue @@ -41,7 +41,7 @@
-
+
-
+
+
{{ post.content }}
+