修改论坛

Change-Id: I93e5d0cb584d8f423d1056ee9a5b84a4ac5f4d07
diff --git a/src/pages/Forum/posts-detail/PostDetailPage.css b/src/pages/Forum/posts-detail/PostDetailPage.css
index e534191..c47601e 100644
--- a/src/pages/Forum/posts-detail/PostDetailPage.css
+++ b/src/pages/Forum/posts-detail/PostDetailPage.css
@@ -1,26 +1,180 @@
-.post-detail-page {
-    padding: 20px;
+   .post-detail-page {
+    background-color: #4b322b;
+    min-height: 100vh;
+    padding: 32px 0;
+    font-family: 'Helvetica Neue', sans-serif;
+    color: #333;
   }
   
-  .post-detail-page h2 {
-    font-size: 2rem;
-    margin-bottom: 10px;
+  .post-detail {
+    background-color: #e9ded2;
+    border-radius: 16px;
+    max-width: 960px;
+    margin: 0 auto;
+    padding: 24px 32px;
+  }
+  
+  .post-detail h1 {
+    font-size: 24px;
+    margin-bottom: 16px;
+    color: #4b322b;
   }
   
   .post-meta {
-    font-size: 1rem;
-    color: #666;
-    margin-bottom: 20px;
+    display: flex;
+    justify-content: space-between;
+    font-size: 14px;
+    color: #755e50;
+    margin-bottom: 16px;
   }
   
   .post-content {
-    font-size: 1.2rem;
+    font-size: 20px;
+    line-height: 1.7;
+    margin-bottom: 20px;
+    color: #4b322b;
   }
   
-  .post-image img {
-    width: 100%;
+  /* 多图排列 */
+  .post-content img {
+    max-width: 180px;
     height: auto;
-    max-width: 600px;
-    margin-top: 20px;
+    border-radius: 8px;
+    margin: 8px;
   }
-  
\ No newline at end of file
+  
+  .post-actions {
+    display: flex;
+    gap: 16px;
+    margin-bottom: 24px;
+    margin-left: 710px;
+  }
+  
+  .icon-btn {
+    display: flex;
+    align-items: center;
+    gap: 6px;
+    border: none;
+    background: none;
+    cursor: pointer;
+    color: #4b322b;
+    transition: transform 0.2s ease;
+  }
+  
+  .icon-btn:hover {
+    background: none !important;
+    color: inherit;
+    outline: none;
+    box-shadow: none;
+  }
+  
+  .comments-section {
+    margin-top: -12px;
+    padding: 24px 24px 16px;
+    border-radius: 12px;
+  }
+  
+  .comments-section h3 {
+    margin-bottom: 16px;
+    font-size: 20px;
+    color: #4b322b;
+    background-color: #c4b3a3;
+    padding: 6px 12px;
+    border-radius: 8px;
+    display: inline-block;
+  }
+
+  .comment {
+    border-bottom: 1px solid #eee;
+    padding: 12px 0;
+  }
+  
+  .comment-header {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    font-size: 0.9rem;
+    color: #555;
+  }
+  
+  .comment-user {
+    font-weight: bold;
+  }
+  
+  .comment-content {
+    margin: 6px 0;
+    font-size: 1rem;
+  }
+  
+  .comment-time {
+    font-size: 0.85rem;
+    color: #999;
+  }
+  
+  .reply-btn {
+    background: none;
+    border: none;
+    color: #000000;
+    cursor: pointer;
+  }
+  
+  .reply-btn:hover {
+    color: #000000; /* 不变色 */
+    background: none; /* 确保没有背景色 */
+    text-decoration: underline; /* 你可以保留这个,或也删除 */
+  }
+  
+  .reply-form,
+  .add-comment-form {
+    margin-top: 12px;
+  }
+  
+  textarea {
+    width: 100%;
+    padding: 12px;
+    resize: vertical;
+    min-height: 80px;
+    border: 1px solid #bbb;
+    border-radius: 10px;
+    font-size: 14px;
+    background-color: #fffefb;
+    color: #333;
+  }
+  
+  .comment-options {
+    margin-top: 8px;
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+  }
+  
+  .comment-options label {
+    font-size: 14px;
+    color: #555;
+  }
+  
+  .comment-options button {
+    padding: 6px 14px;
+    background-color: #BA929A;
+    color: #fff;
+    border: none;
+    border-radius: 6px;
+    font-size: 14px;
+    cursor: pointer;
+    transition: background-color 0.2s ease;
+  }
+  
+  .comment-options button:hover {
+    background-color: #6d4e37;
+  }
+  
+  .error-text {
+    color: #f00;
+    text-align: center;
+  }
+  .post-images {
+    display: flex;
+    flex-wrap: wrap;
+    justify-content: center;
+  }
+    
\ No newline at end of file
diff --git a/src/pages/Forum/posts-detail/PostDetailPage.jsx b/src/pages/Forum/posts-detail/PostDetailPage.jsx
index 5186339..a272fb8 100644
--- a/src/pages/Forum/posts-detail/PostDetailPage.jsx
+++ b/src/pages/Forum/posts-detail/PostDetailPage.jsx
@@ -157,20 +157,25 @@
         <div className="post-detail">
           <h1>{postDetail.title}</h1>
           <div className="post-meta">
+            <span className="post-user">用户ID: {postDetail.user_id}</span>
             <span className="post-time">
-              {new Date(postDetail.postTime).toLocaleString()}
+            发布时间:{new Date(postDetail.postTime).toLocaleString()}
             </span>
-            <span className="post-user">用户 ID: {postDetail.user_id}</span>
           </div>
           <div className="post-content">
             <p>{postDetail.postContent}</p>
-            {postDetail.imgUrl && (
-              <img
-                className="post-image"
-                src={postDetail.imgUrl}
-                alt="帖子图片"
-              />
+            {Array.isArray(postDetail.imgUrl) ? (
+              <div className="post-images">
+                {postDetail.imgUrl.map((url, idx) => (
+                  <img key={idx} src={url} alt={`图片${idx}`} />
+                ))}
+              </div>
+            ) : (
+              postDetail.imgUrl && (
+                <img className="post-image" src={postDetail.imgUrl} alt="帖子图片" />
+              )
             )}
+
           </div>
 
           {/* 点赞和收藏 */}
@@ -181,7 +186,7 @@
             >
               <GoodTwo
                 theme="outline"
-                size="24"
+                size="20"
                 fill={isLiked ? '#f00' : '#ccc'} // 如果已点赞,显示红色
               />
               <span>{postDetail.postLikeNum}</span>
@@ -192,28 +197,28 @@
             >
               <Star
                 theme="outline"
-                size="24"
+                size="20"
                 fill={isCollected ? '#ffd700' : '#ccc'} // 如果已收藏,显示金色
               />
               <span>{postDetail.postCollectNum}</span>
             </button>
           </div>
-
+          
+          <hr className="divider" />
           {/* 评论部分 */}
+          <h3>评论区</h3>
           <div className="comments-section">
-            <h3>评论区</h3>
             {comments.length ? (
               comments.map((comment) => (
                 <div key={comment.commentId} className="comment">
-                  <p>{comment.content}</p>
-                  <div className="comment-meta">
-                    <span className="comment-time">
-                      {new Date(comment.commentTime).toLocaleString()}
-                    </span>
+                  <div className="comment-header">
                     <span className="comment-user">用户 ID: {comment.userId}</span>
+                    <button className="reply-btn" onClick={() => handleReply(comment.commentId)}>回复</button>
                   </div>
-                  {/* 回复按钮 */}
-                  <button onClick={() => handleReply(comment.commentId)}>回复</button>
+                  <p className="comment-content">{comment.content}</p>
+                  <div className="comment-time">
+                    {new Date(comment.commentTime).toLocaleString()}
+                  </div>
 
                   {/* 回复框,只有在当前评论是正在回复的评论时显示 */}
                   {replyToCommentId === comment.commentId && (
diff --git a/src/pages/Forum/posts-main/ForumPage.css b/src/pages/Forum/posts-main/ForumPage.css
index 3f26e17..aa0a5c3 100644
--- a/src/pages/Forum/posts-main/ForumPage.css
+++ b/src/pages/Forum/posts-main/ForumPage.css
@@ -1,6 +1,6 @@
 .forum-page {
     color: #fff;
-    background-color: #2d2d2d;
+    background-color: #4A3B34;
     min-height: 100vh;
     font-family: Arial, sans-serif;
   }
@@ -16,6 +16,7 @@
   }
   
   .post-card {
+    text-decoration: none;  /* 移除链接的下划线 */
     background-color: #4A3B34;
     padding: 15px;
     border-radius: 10px;
@@ -93,4 +94,12 @@
   .error-text {
     color: red;
   }
+
+  .toolbar {
+    display: flex;
+    /* justify-content: space-between; 
+    align-items: center;            */
+    padding: 16px 20px;            
+  }
+  
   
\ No newline at end of file
diff --git a/src/pages/Forum/posts-main/ForumPage.jsx b/src/pages/Forum/posts-main/ForumPage.jsx
index 1452782..bf2aa63 100644
--- a/src/pages/Forum/posts-main/ForumPage.jsx
+++ b/src/pages/Forum/posts-main/ForumPage.jsx
@@ -17,8 +17,9 @@
     <div className="forum-page">
       <Header />
       <div className="toolbar">
-        <SearchBar onSearch={handleSearch} />
         <CreatePostButton />
+        <SearchBar onSearch={handleSearch} />
+        
       </div>
       <PostList search={searchQuery} />
     </div>
diff --git a/src/pages/Forum/posts-main/components/CreatePostButton.css b/src/pages/Forum/posts-main/components/CreatePostButton.css
index c118c7a..b40b9e7 100644
--- a/src/pages/Forum/posts-main/components/CreatePostButton.css
+++ b/src/pages/Forum/posts-main/components/CreatePostButton.css
@@ -4,8 +4,16 @@
     margin: 20px 0;
   }
   
-  .create-post-button {
-    display: flex;
-    align-items: center;
+  .create-btn {
+    background-color: #BA929A;
+    color: white;
+    padding: 10px 20px;
+    border-radius: 8px;
+    border: none;
+    cursor: pointer;
+    font-size: 16px;
+    transition: background-color 0.3s ease;
   }
+
+  
   
\ No newline at end of file
diff --git a/src/pages/Forum/posts-main/components/PostList.css b/src/pages/Forum/posts-main/components/PostList.css
index d855c07..59533ff 100644
--- a/src/pages/Forum/posts-main/components/PostList.css
+++ b/src/pages/Forum/posts-main/components/PostList.css
@@ -2,10 +2,12 @@
     display: flex;
     flex-direction: column;
     gap: 16px;
+    padding: 30px;
   }
   
   .post-card {
-    border: 1px solid #eee;
+    background-color: #e9ded2;
+    border: 1px solid #000000;
     padding: 16px;
     border-radius: 8px;
   }
diff --git a/src/pages/Forum/posts-main/components/PostList.jsx b/src/pages/Forum/posts-main/components/PostList.jsx
index 7ad0a86..25b08a8 100644
--- a/src/pages/Forum/posts-main/components/PostList.jsx
+++ b/src/pages/Forum/posts-main/components/PostList.jsx
@@ -115,43 +115,45 @@
         errorMsg ? <p className="error-text">{errorMsg}</p> :
           posts.length === 0 ? <p>暂无帖子。</p> :
             posts.map(post => (
-              <div key={post.id} className="post-card">
-                <div className="post-card-top">
-                  <div className="user-info">
-                    <img className="avatar" src={post.userProfile.avatar_url} alt="头像" />
-                    <span className="nickname">{post.userProfile.nickname}</span>
+              <Link
+                key={post.id}
+                href={`/forum/post/${post.id}`}
+                className="post-card"
+                style={{ backgroundColor: '#e9ded2' }}
+              >
+                <div className="user-info">
+                  <img className="avatar" src={post.userProfile.avatar_url} alt="头像" />
+                  <span className="nickname" style={{ color: '#755e50' }}>{post.userProfile.nickname}</span>
+                </div>
+                {post.cover_image_url && (
+                  <img className="cover-image" src={post.cover_image_url} alt="封面" />
+                )}
+                <h3 style={{ color: '#000000' }}>{post.title}</h3>
+                <div className="post-meta">
+                  <span>发布时间:{new Date(post.createdAt).toLocaleString()}</span>
+                  <div className="post-actions">
+                    {/* 点赞按钮 */}
+                    <button className="icon-btn" onClick={(e) => { e.stopPropagation(); toggleLike(post.id, post.liked, post.user_id); }}>
+                      <GoodTwo theme="outline" size="24" fill={post.liked ? '#f00' : '#fff'} />
+                      <span>{post.likeCount}</span>
+                    </button>
+  
+                    {/* 收藏按钮 */}
+                    <button className="icon-btn" onClick={(e) => { e.stopPropagation(); toggleCollect(post.id, post.collected, post.user_id); }}>
+                      <Star theme="outline" size="24" fill={post.collected ? '#ffd700' : '#fff'} />
+                      <span>{post.collectCount}</span>
+                    </button>
+  
+                    <Link href={`/forum/post/${post.id}`} className="icon-btn" onClick={(e) => e.stopPropagation()}>
+                      <Comment theme="outline" size="24" fill="#fff" />
+                      <span>{post.commentCount}</span>
+                    </Link>
                   </div>
-                  {post.cover_image_url && (
-                    <img className="cover-image" src={post.cover_image_url} alt="封面" />
-                  )}
                 </div>
-                <h3>{post.title}</h3>
-                <p className="post-meta">
-                  发布时间:{new Date(post.createdAt).toLocaleString()}
-                </p>
-                <div className="post-actions">
-                  {/* 点赞按钮 */}
-                  <button className="icon-btn" onClick={() => toggleLike(post.id, post.liked, post.user_id)}>
-                    <GoodTwo theme="outline" size="24" fill={post.liked ? '#f00' : '#fff'} />
-                    <span>{post.likeCount}</span>
-                  </button>
-
-                  {/* 收藏按钮 */}
-                  <button className="icon-btn" onClick={() => toggleCollect(post.id, post.collected, post.user_id)}>
-                    <Star theme="outline" size="24" fill={post.collected ? '#ffd700' : '#fff'} />
-                    <span>{post.collectCount}</span>
-                  </button>
-
-                  <Link href={`/forum/post/${post.id}`} className="icon-btn">
-                    <Comment theme="outline" size="24" fill="#fff" />
-                    <span>{post.commentCount}</span>
-                  </Link>
-                </div>
-                <Link href={`/forum/post/${post.id}`} className="btn-secondary">查看详情</Link>
-              </div>
+              </Link>
             ))
       }
-
+  
       <div className="pagination">
         <button disabled={page === 1} onClick={() => setPage(page - 1)}>上一页</button>
         <span>第 {page} 页 / 共 {totalPages} 页</span>
@@ -162,3 +164,170 @@
 };
 
 export default PostList;
+
+// import React, { useEffect, useState } from 'react';
+// import axios from 'axios';
+// import { Link } from 'wouter';
+// import { GoodTwo, Comment, Star } from '@icon-park/react';
+// import { likePost, unlikePost, collectPost } from '../../posts-detail/api'; 
+// import './PostList.css';
+
+// const API_BASE = process.env.REACT_APP_API_BASE;
+
+// const PostList = ({ search }) => {
+//   const [posts, setPosts] = useState([]);
+//   const [page, setPage] = useState(1);
+//   const [total, setTotal] = useState(0);
+//   const [loading, setLoading] = useState(true);
+//   const [errorMsg, setErrorMsg] = useState('');
+
+//   const size = 10;  // 每页条数
+//   const totalPages = Math.ceil(total / size);
+
+//   useEffect(() => {
+//     const fetchPosts = async () => {
+//       setLoading(true);
+//       setErrorMsg('');
+//       try {
+//         const res = await axios.get(`${API_BASE}/echo/forum/posts`, {
+//           params: { 
+//             page: page,
+//             pageSize: size,
+//             sortBy: 'createdAt',  // 按时间排序
+//             order: 'desc'         // 按降序排序
+//           }
+//         });
+
+//         const postsData = res.data.posts || [];
+//         const userIds = [...new Set(postsData.map(p => p.user_id))];
+
+//         // 获取用户信息
+//         const profiles = await Promise.all(userIds.map(async id => {
+//           try {
+//             const r = await axios.get(`${API_BASE}/echo/user/profile`, {
+//               params: { user_id: id }
+//             });
+//             return { id, profile: r.data };
+//           } catch {
+//             return { id, profile: { nickname: '未知用户', avatar_url: 'default-avatar.png' } };
+//           }
+//         }));
+
+//         const userMap = {};
+//         profiles.forEach(({ id, profile }) => { userMap[id] = profile; });
+
+//         // 更新帖子数据
+//         const postsWithProfiles = postsData
+//           .filter(post => post.title.includes(search))
+//           .map(post => ({
+//             ...post,
+//             userProfile: userMap[post.user_id] || {}
+//           }));
+
+//         setPosts(postsWithProfiles);
+//         setTotal(res.data.total || 0);
+//       } catch (err) {
+//         console.error('加载失败:', err);
+//         setErrorMsg('加载失败,请稍后重试');
+//       } finally {
+//         setLoading(false);
+//       }
+//     };
+
+//     fetchPosts();
+//   }, [page, search]);
+
+//   // 点赞/取消点赞操作
+//   const toggleLike = async (postId, liked, userId) => {
+//     try {
+//       if (liked) {
+//         await unlikePost(postId);  // 取消点赞
+//       } else {
+//         await likePost(postId, userId);  // 点赞
+//       }
+
+//       setPosts(posts =>
+//         posts.map(post =>
+//           post.id === postId
+//             ? { ...post, liked: !liked, likeCount: liked ? post.likeCount - 1 : post.likeCount + 1 }
+//             : post
+//         )
+//       );
+//     } catch (err) {
+//       console.error('点赞失败:', err);
+//     }
+//   };
+
+//   // 收藏/取消收藏操作
+//   const toggleCollect = async (postId, collected, userId) => {
+//     try {
+//       const action = collected ? 'cancel' : 'collect';
+//       await collectPost(postId, userId, action);
+
+//       setPosts(posts =>
+//         posts.map(post =>
+//           post.id === postId
+//             ? { ...post, collected: !collected, collectCount: collected ? post.collectCount - 1 : post.collectCount + 1 }
+//             : post
+//         )
+//       );
+//     } catch (err) {
+//       console.error('收藏失败:', err);
+//     }
+//   };
+//   return (
+//     <div className="post-list">
+//       {loading ? <p>加载中...</p> :
+//         errorMsg ? <p className="error-text">{errorMsg}</p> :
+//           posts.length === 0 ? <p>暂无帖子。</p> :
+//             posts.map(post => (
+//               <Link
+//                 key={post.id}
+//                 href={`/forum/post/${post.id}`}
+//                 className="post-card"
+//                 style={{ backgroundColor: '#e9ded2' }}
+//               >
+//                 <div className="user-info">
+//                   <img className="avatar" src={post.userProfile.avatar_url} alt="头像" />
+//                   <span className="nickname" style={ { color: '#755e50' } }>{post.userProfile.nickname}</span>
+//                 </div>
+//                 {post.cover_image_url && (
+//                   <img className="cover-image" src={post.cover_image_url} alt="封面" />
+//                 )}
+//                 <h3 style={ { color: '#000000' } }>{post.title}</h3>
+//                 <p className="post-meta">
+//                   发布时间:{new Date(post.createdAt).toLocaleString()}
+//                 </p>
+//                 <div className="post-actions">
+//                   {/* 点赞按钮 */}
+//                   <button className="icon-btn" onClick={(e) => { e.stopPropagation(); toggleLike(post.id, post.liked, post.user_id); }}>
+//                     <GoodTwo theme="outline" size="24" fill={post.liked ? '#f00' : '#fff'} />
+//                     <span>{post.likeCount}</span>
+//                   </button>
+  
+//                   {/* 收藏按钮 */}
+//                   <button className="icon-btn" onClick={(e) => { e.stopPropagation(); toggleCollect(post.id, post.collected, post.user_id); }}>
+//                     <Star theme="outline" size="24" fill={post.collected ? '#ffd700' : '#fff'} />
+//                     <span>{post.collectCount}</span>
+//                   </button>
+  
+//                   <Link href={`/forum/post/${post.id}`} className="icon-btn" onClick={(e) => e.stopPropagation()}>
+//                     <Comment theme="outline" size="24" fill="#fff" />
+//                     <span>{post.commentCount}</span>
+//                   </Link>
+//                 </div>
+//               </Link>
+//             ))
+//       }
+  
+//       <div className="pagination">
+//         <button disabled={page === 1} onClick={() => setPage(page - 1)}>上一页</button>
+//         <span>第 {page} 页 / 共 {totalPages} 页</span>
+//         <button disabled={page === totalPages} onClick={() => setPage(page + 1)}>下一页</button>
+//       </div>
+//     </div>
+//   );
+  
+// };
+
+// export default PostList;
diff --git a/src/pages/Forum/posts-main/components/SearchBar.css b/src/pages/Forum/posts-main/components/SearchBar.css
index b74f9d2..60ba679 100644
--- a/src/pages/Forum/posts-main/components/SearchBar.css
+++ b/src/pages/Forum/posts-main/components/SearchBar.css
@@ -3,5 +3,19 @@
     align-items: center;
     gap: 10px;
     margin-bottom: 20px;
+    margin-top: 20px;
+    margin-left: 950px;
   }
-  
\ No newline at end of file
+  
+  .search-btn {
+    margin-right: -3px;
+    background-color: #e9ded2;
+    /* 文字颜色 */
+    color: #4b322b;
+    padding: 8px 10px;     /* 控制按钮的高度和宽度 */
+    font-size: 15px;       /* 控制文字大小 */
+  }
+
+  .search-input {
+    font-size: 15px;       /* 控制文字大小 */
+  }
\ No newline at end of file