修改个人中心、发布种子、兴趣小组

Change-Id: I73caa8ef511ad9ae12a0cc49fc0edb5ccb0b2a74
diff --git a/src/pages/SeedList/SeedDetail/SeedDetail.css b/src/pages/SeedList/SeedDetail/SeedDetail.css
index ce4d70e..242fd83 100644
--- a/src/pages/SeedList/SeedDetail/SeedDetail.css
+++ b/src/pages/SeedList/SeedDetail/SeedDetail.css
@@ -1,30 +1,123 @@
-.seed-detail-container {
-    padding: 20px;
-  }
-  
-  .seed-header {
-    display: flex;
-  }
-  
-  .cover-image {
-    width: 200px;
-    height: auto;
-    margin-right: 20px;
-    border-radius: 8px;
-  }
-  
-  .seed-basic-info p, .seed-media-info p {
-    margin: 6px 0;
-  }
-  
-  .uploader-info {
-    margin-top: 30px;
-    border-top: 1px solid #ccc;
-    padding-top: 10px;
-  }
-  
-  .uploader-info .avatar {
-    width: 60px;
-    border-radius: 50%;
-  }
+.seed-detail-page {
+  background-color: #4b322b;
+  min-height: 100vh;
+  padding: 32px 0;
+  font-family: 'Helvetica Neue', sans-serif;
+  color: #333;
+}
+
+.seed-detail {
+  background-color: #e9ded2;
+  border-radius: 16px;
+  max-width: 960px;
+  margin: 0 auto;
+  margin-top: 40px;
+  padding: 24px 32px;
+}
+
+.seed-detail h1 {
+  font-size: 24px;
+  font-weight: bold;
+  margin-bottom: 16px;
+  color: #4b322b;
+}
+
+.seed-header-container {
+  display: flex;
+  justify-content: space-between;
+  align-items: flex-start;
+}
+
+.seed-info {
+  flex: 1;
+}
+
+.seed-basic-info p,
+.seed-media-info p {
+  font-size: 16px;
+  margin: 6px 0;
+}
+
+.cover-image {
+  width: 200px;
+  height: auto;
+  margin-left: 20px;
+  border-radius: 8px;
+}
+
+.comment-options {
+  margin-top: 8px;
+  display: flex;
+  justify-content: flex-end; /* 将 space-between 改为 flex-end */
+}
+
+.action-buttons {
+  justify-content: flex-end; /*靠右对齐*/
+  display: flex;
+  gap: 10px;
+  margin-bottom: 20px;
+}
+
+.btn {
+  justify-content: flex-end; /*靠右对齐*/
+  padding: 6px 14px;
+  background-color: #BA929A;
+  color: #fff;
+  border: none;
+  border-radius: 6px;
+  font-size: 14px;
+  cursor: pointer;
+}
+
+.btn:hover {
+  background-color: #6d4e37;
+}
+
+.comments-section {
+  margin-top: 20px;
+}
+
+.comments-section h3 {
+  margin-bottom: 10px;
+  font-size: 20px;
+  color: #4b322b;
+}
+
+.comments-list {
+  border-top: 1px solid #ccc;
+  padding-top: 10px;
+}
+
+.comment {
+  border-bottom: 1px solid #ccc;
+  padding: 10px 0;
+}
+
+.comment-user {
+  font-weight: bold;
+  margin-bottom: 5px;
+}
+
+.comment-content {
+  margin: 0;
+}
+
+.add-comment-form {
+  margin-top: 10px;
+}
+
+.add-comment-form textarea {
+  width: 100%;
+  padding: 10px;
+  resize: vertical;
+  min-height: 80px;
+  border: 1px solid #bbb;
+  border-radius: 6px;
+  margin-bottom: 10px;
+}
+
+.error-text {
+  color: #f00;
+  text-align: center;
+}
   
\ No newline at end of file
diff --git a/src/pages/SeedList/SeedDetail/SeedDetail.jsx b/src/pages/SeedList/SeedDetail/SeedDetail.jsx
index 464da3d..b99fcc5 100644
--- a/src/pages/SeedList/SeedDetail/SeedDetail.jsx
+++ b/src/pages/SeedList/SeedDetail/SeedDetail.jsx
@@ -7,83 +7,161 @@
 const API_BASE = process.env.REACT_APP_API_BASE;
 
 const SeedDetail = () => {
-  const { seed_id } = useParams();
-  const [seed, setSeed] = useState(null);
-  const [error, setError] = useState(null);
+    const { seed_id } = useParams();
+    const [seed, setSeed] = useState(null);
+    const [error, setError] = useState(null);
+    const [comments, setComments] = useState([]);
+    const [newComment, setNewComment] = useState('');
 
-  useEffect(() => {
-    axios
-      .get(`${API_BASE}/echo/seeds/${seed_id}`)
-      .then((res) => {
-        if (res.data.status === 'success') {
-          setSeed(res.data.seed);
-        } else {
-          setError('未能获取种子信息');
+    useEffect(() => {
+        axios
+           .get(`${API_BASE}/echo/seeds/${seed_id}`)
+           .then((res) => {
+                if (res.data.status === 'success') {
+                    setSeed(res.data.seed);
+                } else {
+                    setError('未能获取种子信息');
+                }
+            })
+           .catch(() => {
+                setError('获取种子详情失败');
+            });
+
+        // 模拟获取评论数据,实际需要调用 API
+        axios.get(`${API_BASE}/echo/seeds/${seed_id}/comments`)
+           .then((res) => {
+                if (res.data.status === 'success') {
+                    setComments(res.data.comments);
+                }
+            })
+           .catch(() => {
+                console.log('获取评论失败');
+            });
+    }, [seed_id]);
+
+    const handleDownload = async () => {
+        if (seed) {
+            const peer_id = 'echo-' + Math.random().toString(36).substring(2, 10);
+            const ip = '127.0.0.1';
+            const port = 6881;
+            const uploaded = 0;
+            const downloaded = 0;
+            const left = 0;
+
+            try {
+                const response = await axios.get(`${API_BASE}/echo/seeds/${seed.seed_id}/download`, {
+                    params: { peer_id, ip, port, uploaded, downloaded, left },
+                    responseType: 'blob'
+                });
+
+                const blob = new Blob([response.data], { type: 'application/x-bittorrent' });
+                const downloadUrl = URL.createObjectURL(blob);
+                const a = document.createElement('a');
+                a.href = downloadUrl;
+                a.download = `${seed.seed_id}.torrent`;
+                a.click();
+                URL.revokeObjectURL(downloadUrl);
+            } catch (error) {
+                console.error('下载失败:', error);
+                alert('下载失败,请稍后再试。');
+            }
         }
-      })
-      .catch(() => {
-        setError('获取种子详情失败');
-      });
-  }, [seed_id]);
+    };
 
-  if (error) {
+    const handleCollect = () => {
+        // 这里可以添加收藏逻辑,调用相应 API
+        alert('已收藏');
+    };
+
+    const handleAddComment = () => {
+        if (newComment.trim()) {
+            // 这里可以添加评论逻辑,调用相应 API
+            setComments([...comments, { content: newComment, user: '用户' }]);
+            setNewComment('');
+        }
+    };
+
+    if (error) {
+        return (
+            <div className="seed-detail-page">
+                <Header />
+                <div className="seed-detail">
+                    <p className="error-text">{error}</p>
+                </div>
+            </div>
+        );
+    }
+
+    if (!seed) {
+        return (
+            <div className="seed-detail-page">
+                <Header />
+                <div className="seed-detail">
+                    <p>加载中...</p>
+                </div>
+            </div>
+        );
+    }
+
     return (
-      <div>
-        <Header />
-        <div className="seed-detail-container">
-          <p className="error">{error}</p>
+        <div className="seed-detail-page">
+            <Header />
+            <div className="seed-detail">
+                <h1>{seed.title}</h1>
+                <div className="seed-header-container">
+                    <div className="seed-info">
+                        <div className="seed-basic-info">
+                            <p><strong>分类:</strong>{seed.category}</p>
+                            <p><strong>发布时间:</strong>{new Date(seed.upload_time).toLocaleString()}</p>
+                            <p><strong>标签:</strong>{seed.tags.join(' / ')}</p>
+                            <p><strong>简介:</strong>{seed.description}</p>
+                            <p><strong>大小:</strong>{seed.size} GB</p>
+                            <p><strong>分辨率:</strong>{seed.resolution}</p>
+                            <p><strong>片长:</strong>{seed.duration}</p>
+                            <p><strong>地区:</strong>{seed.region}</p>
+                            <p><strong>下载次数:</strong>{seed.downloads}</p>
+                        </div>
+                        {(seed.category === '电影' || seed.category === '电视剧') && (
+                            <div className="seed-media-info">
+                                <p><strong>导演:</strong>{seed.director}</p>
+                                <p><strong>编剧:</strong>{seed.writer}</p>
+                                <p><strong>主演:</strong>{seed.actors.join(' / ')}</p>
+                            </div>
+                        )}
+                    </div>
+                    <img src={seed.cover_url} alt={seed.title} className="cover-image" />
+                </div>
+                <div className="action-buttons">
+                    <button className="btn" onClick={handleDownload}>下载</button>
+                    <button className="btn" onClick={handleCollect}>收藏</button>             
+                </div>
+                <hr className="divider" />
+                {/* 评论部分 */}
+                <h3>评论区</h3>
+                <div className="comments-section">
+                    <div className="comments-list">
+                        {comments.map((comment, index) => (
+                            <div key={index} className="comment">
+                                <p className="comment-user">{comment.user}</p>
+                                <p className="comment-content">{comment.content}</p>
+                            </div>
+                        ))}
+                    </div>
+                    <div className="add-comment-form">
+                        <textarea
+                            placeholder="输入你的评论..."
+                            value={newComment}
+                            onChange={(e) => setNewComment(e.target.value)}
+                        />
+                        <div className="comment-options">
+                        <button className="btn" onClick={handleAddComment}>发布评论</button>
+                        </div>
+                    </div>
+                </div>
+            </div>
         </div>
-      </div>
     );
-  }
-
-  if (!seed) {
-    return (
-      <div>
-        <Header />
-        <div className="seed-detail-container">
-          <p>加载中...</p>
-        </div>
-      </div>
-    );
-  }
-
-  return (
-    <div>
-      <Header />
-      <div className="seed-detail-container">
-        <div className="seed-header">
-          <img src={seed.cover_url} alt={seed.title} className="cover-image" />
-          <div className="seed-basic-info">
-            <h1>{seed.title}</h1>
-            <p><strong>分类:</strong>{seed.category}</p>
-            <p><strong>标签:</strong>{seed.tags.join(' / ')}</p>
-            <p><strong>简介:</strong>{seed.description}</p>
-            <p><strong>大小:</strong>{seed.size} GB</p>
-            <p><strong>分辨率:</strong>{seed.resolution}</p>
-            <p><strong>片长:</strong>{seed.duration}</p>
-            <p><strong>地区:</strong>{seed.region}</p>
-            <p><strong>发布时间:</strong>{new Date(seed.upload_time).toLocaleString()}</p>
-            <p><strong>下载次数:</strong>{seed.downloads}</p>
-          </div>
-        </div>
-
-        {(seed.category === '电影' || seed.category === '电视剧') && (
-          <div className="seed-media-info">
-            <p><strong>导演:</strong>{seed.director}</p>
-            <p><strong>编剧:</strong>{seed.writer}</p>
-            <p><strong>主演:</strong>{seed.actors.join(' / ')}</p>
-          </div>
-        )}
-
-        <div className="uploader-info">
-          <h3>发种人</h3>
-          <img src={seed.user.avatar_url} alt={seed.user.username} className="avatar" />
-          <p>{seed.user.username}</p>
-        </div>
-      </div>
-    </div>
-  );
 };
 
 export default SeedDetail;
+    
\ No newline at end of file
diff --git a/src/pages/SeedList/SeedList.css b/src/pages/SeedList/SeedList.css
index 94c70aa..724411c 100644
--- a/src/pages/SeedList/SeedList.css
+++ b/src/pages/SeedList/SeedList.css
@@ -1,6 +1,6 @@
       
        .main-page {
-        background-color: #5c3f31;
+        background-color: #5F4437;
         color: white;
       }
       
@@ -10,7 +10,7 @@
         justify-content: center;
         gap: 16px;
         padding: 10px 20px;
-        background-color: #5c3f31;
+        background-color: #5F4437;
       }
       
       .search-input {
@@ -28,7 +28,7 @@
       
       /* 标签过滤 */
       .tag-filters {
-        background-color: #5c3f31;
+        background-color: #5F4437;
         display: flex;
         justify-content: center;
         flex-wrap: wrap;
@@ -72,7 +72,7 @@
       /* 卡片展示 */
       .seed-list-content {
         padding: 20px;
-        background-color: #5c3f31;
+        background-color: #5F4437;
       }
       
       .seed-list-card {
@@ -233,7 +233,7 @@
         margin-bottom: 12px;
       }
       .friend-moments {
-        background-color: #5c3f31;
+        background-color: #5F4437;
         color: white;
       }
           
\ No newline at end of file