From 4ab9a50eed27b9209f9ca6fda0071f04d261cef1 Mon Sep 17 00:00:00 2001 From: 2991692032 Date: Wed, 28 May 2025 11:00:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BA=E5=9D=9B=E5=8A=9F=E8=83=BD=E5=89=8D?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=E9=9B=86=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unilife-frontend/src/api/auth.ts | 18 ++ unilife-frontend/src/api/forum.ts | 61 ++++ unilife-frontend/src/utils/api-test.ts | 1 + .../src/views/forum/ForumView.vue | 296 ++++++++++++++---- .../src/views/forum/PostDetailView.vue | 246 ++++++++++----- .../java/com/unilife/config/WebMvcConfig.java | 6 +- .../unilife/controller/PostController.java | 4 +- .../java/com/unilife/model/vo/PostListVO.java | 5 + .../java/com/unilife/service/PostService.java | 3 +- .../unilife/service/impl/PostServiceImpl.java | 26 +- 10 files changed, 500 insertions(+), 166 deletions(-) create mode 100644 unilife-frontend/src/utils/api-test.ts 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 }}
+