完成上传下载连接,公告管理与详情页面,求种区页面,轮播图折扣显示,修改部分bug

Change-Id: I86fc294e32911cb3426a8b16f90aca371f975c11
diff --git a/src/components/HelpDetail.jsx b/src/components/HelpDetail.jsx
index 7e7b7c8..1e35aec 100644
--- a/src/components/HelpDetail.jsx
+++ b/src/components/HelpDetail.jsx
@@ -1,16 +1,16 @@
 import React, { useState, useEffect, useRef } from 'react';

 import { useParams, useNavigate, useLocation } from 'react-router-dom';

 import { 

-  getPostDetail,

-  addPostComment,

-  likePost,

-  deletePost

+  getHelpPostDetail,

+  addHelpPostComment,

+  likeHelpPost,

+  deleteHelpPost

 } from '../api/helpPost';

 import {

-  likePostComment,

+  likeHelpPostComment,

   getCommentReplies,

-  addCommentReply,

-  deleteComment

+  addHelpCommentReply,

+  deleteHelpComment

 } from '../api/helpComment';

 import './HelpDetail.css';

 

@@ -136,7 +136,7 @@
    const fetchPostDetail = async () => {

       try {

         setLoading(true);

-        const response = await getPostDetail(id);

+        const response = await getHelpPostDetail(id);

         console.log('API Response:', JSON.parse(JSON.stringify(response.data.data.comments))); // 深度拷贝避免Proxy影响

         setPost(response.data.data.post);

         setComments(response.data.data.comments);

@@ -154,7 +154,7 @@
     // 点赞帖子

     const handleLikePost = async () => {

       try {

-        await likePost(id);

+        await likeHelpPost(id);

         setPost(prev => ({

           ...prev,

           likeCount: prev.likeCount + 1

@@ -169,7 +169,7 @@
       if (window.confirm('确定要删除这个帖子吗?所有评论也将被删除!')) {

         try {

           const username = localStorage.getItem('username');

-          await deletePost(postId, username);

+          await deleteHelpPost(postId, username);

           navigate('/dashboard/help'); // 删除成功后返回求助区

         } catch (err) {

           setError('删除失败: ' + (err.response?.data?.message || err.message));

@@ -183,16 +183,21 @@
       

       try {

         const username = localStorage.getItem('username');

-        const response = await addPostComment(id, {

-          content: newComment,

-          authorId: username

-        });

+        const formData = new FormData();

+        formData.append('content', newComment);

+        formData.append('authorId', username);

+        if (commentImage) {

+          formData.append('image', commentImage);

+        }

+

+        const response = await addHelpPostComment(id, formData);

     

         // 修改这里的响应处理逻辑

         if (response.data && response.data.code === 200) {

           await fetchPostDetail();

           

           setNewComment('');

+          setCommentImage(null); // 清空评论图片

         } else {

           setError(response.data.message || '评论失败');

         }

@@ -204,7 +209,7 @@
     

     const handleLikeComment = async (commentId) => {

       try {

-        await likePostComment(commentId);

+        await likeHelpPostComment(commentId);

         

         // 递归更新评论点赞数

         const updateComments = (comments) => {

@@ -236,7 +241,7 @@
       if (window.confirm('确定要删除这条评论吗?')) {

         try {

           const username = localStorage.getItem('username');

-          await deleteComment(commentId, username);

+          await deleteHelpComment(commentId, username);

           await fetchPostDetail(); // 刷新评论列表

         } catch (err) {

           setError('删除失败: ' + (err.response?.data?.message || err.message));

@@ -264,7 +269,7 @@
     

       try {

         const username = localStorage.getItem('username');

-        const response = await addCommentReply(replyModal.replyingTo, {

+        const response = await addHelpCommentReply(replyModal.replyingTo, {

           authorId: username,

           content: replyContent,

           image: replyImage