添加兴趣小组页面

Change-Id: Ia76dfe732bb60b0f93534706a5deedb4de3eaf05
diff --git a/src/App.js b/src/App.js
index 90db851..b824fe1 100644
--- a/src/App.js
+++ b/src/App.js
@@ -5,7 +5,8 @@
 import SeedList from './pages/SeedList/SeedList';
 import { UserProvider } from './context/UserContext';
 import PublishSeed from './pages/PublishSeed/PublishSeed';
-import SeedDetail from './pages/SeedList/SeedDetail/SeedDetail'; // 引入 SeedDetail 页面
+import SeedDetail from './pages/SeedList/SeedDetail/SeedDetail'; 
+import InterestGroup from './pages/InterestGroup/InterestGroup';
 
 function App() {
   return (
@@ -17,6 +18,7 @@
         <Route path="/seed-list" component={SeedList} />
         <Route path="/publish-seed" component={PublishSeed} />
         <Route path="/seed/:seed_id" component={SeedDetail} /> {/* 新增路由 */}
+        <Route path="/interest-groups" component={InterestGroup}/>
       </Switch>
     </UserProvider>
   );
diff --git a/src/pages/InterestGroup/InterestGroup.css b/src/pages/InterestGroup/InterestGroup.css
new file mode 100644
index 0000000..a52ba5f
--- /dev/null
+++ b/src/pages/InterestGroup/InterestGroup.css
@@ -0,0 +1,158 @@
+/* 设置整个兴趣小组页面的背景色和布局 */
+.interest-group-container {
+    background-color: #f8f1f1; /* 粉色背景 */
+    width: 100%;
+  }
+  
+  /* 页面标题样式 */
+  h1 {
+    text-align: center;
+    color: #5c3f31; /* 深棕色 */
+    font-size: 2rem;
+    margin-bottom: 30px;
+  }
+  
+  /* 筛选部分样式 */
+  .filter, .search, .sort {
+    margin-bottom: 20px;
+    text-align: center;
+  }
+  
+  .filter select,
+  .search input,
+  .sort select {
+    padding: 10px;
+    width: 200px;
+    border-radius: 6px;
+    border: 1px solid #e0c4a1; /* 浅棕色 */
+    background-color: #fff5f5; /* 浅粉色 */
+    color: #5c3f31;
+    font-size: 1rem;
+  }
+  
+  /* 激活时的输入框样式 */
+  .filter select:focus,
+  .search input:focus,
+  .sort select:focus {
+    border-color: #b38867; /* 较深的棕色 */
+    outline: none;
+  }
+  
+  /* 小组列表样式 */
+  .group-list {
+    display: flex;
+    flex-wrap: wrap;
+    gap: 20px;
+    justify-content: space-between;
+  }
+  
+  /* 每个小组的容器 */
+  .group-item {
+    width: 30%;
+    border: 1px solid #e0c4a1; /* 浅棕色边框 */
+    border-radius: 8px;
+    overflow: hidden;
+    background-color: #fff;
+    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
+    transition: transform 0.3s ease-in-out;
+  }
+  
+  .group-item:hover {
+    transform: translateY(-5px); /* 鼠标悬停时小组项上升效果 */
+  }
+  
+  /* 小组封面图样式 */
+  .group-cover {
+    width: 100%;
+    height: 180px;
+    object-fit: cover;
+    transition: opacity 0.3s ease;
+  }
+  
+  /* 小组信息区域 */
+  .group-info {
+    padding: 15px;
+    background-color: #f8f1f1; /* 浅粉色背景 */
+  }
+  
+  .group-info h2 {
+    font-size: 1.2em;
+    color: #5c3f31;
+    margin-bottom: 10px;
+  }
+  
+  /* 小组描述部分 */
+  .group-info p {
+    font-size: 1rem;
+    color: #5c3f31;
+  }
+  
+  /* 分页按钮 */
+  .pagination {
+    text-align: center;
+    margin-top: 30px;
+  }
+  
+  button {
+    padding: 10px 20px;
+    margin: 0 10px;
+    background-color: #5c3f31; /* 深棕色 */
+    color: white;
+    border: none;
+    border-radius: 6px;
+    cursor: pointer;
+    font-size: 1rem;
+    transition: background-color 0.3s ease;
+  }
+  
+  button:disabled {
+    background-color: #d6d6d6;
+    cursor: not-allowed;
+  }
+  
+  button:hover {
+    background-color: #b38867; /* 深棕色的 hover 效果 */
+  }
+  
+  /* 错误信息的样式 */
+  .error {
+    color: #ff6f61; /* 红色 */
+    text-align: center;
+    margin-top: 20px;
+  }
+  
+  /* 加载中的提示 */
+  .loading {
+    color: #5c3f31;
+    text-align: center;
+    margin-top: 20px;
+    font-size: 1.2rem;
+  }
+  
+  /* 响应式设计: 确保在小屏幕下布局能适应 */
+  @media (max-width: 768px) {
+    .group-item {
+      width: 48%;
+    }
+  
+    .filter select,
+    .search input,
+    .sort select {
+      width: 100%;
+      margin-bottom: 10px;
+    }
+  }
+  
+  @media (max-width: 480px) {
+    .group-item {
+      width: 100%;
+    }
+  
+    .filter select,
+    .search input,
+    .sort select {
+      width: 100%;
+      font-size: 0.9rem;
+    }
+  }
+  
\ No newline at end of file
diff --git a/src/pages/InterestGroup/InterestGroup.jsx b/src/pages/InterestGroup/InterestGroup.jsx
new file mode 100644
index 0000000..c1109a0
--- /dev/null
+++ b/src/pages/InterestGroup/InterestGroup.jsx
@@ -0,0 +1,155 @@
+import React, { useEffect, useState } from 'react';
+import axios from 'axios';
+import './InterestGroup.css';
+import Header from '../../components/Header'; // 导入 Header 组件
+
+const API_BASE = process.env.REACT_APP_API_BASE;
+
+const InterestGroup = () => {
+  const [groups, setGroups] = useState([]);
+  const [loading, setLoading] = useState(true);
+  const [error, setError] = useState(null);
+  const [category, setCategory] = useState('');
+  const [name, setName] = useState('');
+  const [page, setPage] = useState(1);
+  const [size, setSize] = useState(10);
+  const [totalPages, setTotalPages] = useState(1);
+  const [sortBy, setSortBy] = useState('member_count'); // 默认按照成员数排序
+
+  useEffect(() => {
+    // 请求兴趣小组列表
+    const fetchGroups = async () => {
+      try {
+        setLoading(true);
+        setError(null);
+        const response = await axios.get(`${API_BASE}/echo/groups`, {
+          params: {
+            category,
+            name,
+            page,
+            size,
+            sort_by: sortBy
+          }
+        });
+
+        if (response.data.status === 'success') {
+          setGroups(response.data.items);
+          setTotalPages(response.data.total_pages); // 更新总页数
+        } else {
+          setError('获取兴趣小组列表失败');
+        }
+      } catch (err) {
+        setError('请求失败,请稍后再试');
+      } finally {
+        setLoading(false);
+      }
+    };
+
+    fetchGroups();
+  }, [category, name, page, size, sortBy]);
+
+  const handleCategoryChange = (e) => {
+    setCategory(e.target.value);
+    setPage(1); // 重置为第一页
+  };
+
+  const handleSearchChange = (e) => {
+    setName(e.target.value);
+    setPage(1); // 重置为第一页
+  };
+
+  const handleSortChange = (e) => {
+    setSortBy(e.target.value);
+  };
+
+  const handlePageChange = (newPage) => {
+    if (newPage > 0 && newPage <= totalPages) {
+      setPage(newPage);
+    }
+  };
+
+  return (
+    <div className="interest-group-container">
+      {/* Header 组件放在页面最上方 */}
+      <Header />
+
+      <h1>兴趣小组列表</h1>
+      {/* 分类筛选 */}
+      <div className="filter">
+        <label>分类:</label>
+        <select onChange={handleCategoryChange} value={category}>
+          <option value="">全部</option>
+          <option value="影视">影视</option>
+          <option value="游戏">游戏</option>
+          <option value="学习">学习</option>
+          <option value="体育">体育</option>
+          <option value="其他">其他</option>
+        </select>
+      </div>
+
+      {/* 搜索框 */}
+      <div className="search">
+        <label>搜索:</label>
+        <input
+          type="text"
+          value={name}
+          onChange={handleSearchChange}
+          placeholder="输入小组名称搜索"
+        />
+      </div>
+
+      {/* 排序 */}
+      <div className="sort">
+        <label>排序:</label>
+        <select onChange={handleSortChange} value={sortBy}>
+          <option value="member_count">按成员数排序</option>
+          <option value="name">按名称排序</option>
+          <option value="category">按分类排序</option>
+        </select>
+      </div>
+
+      {/* 加载中提示 */}
+      {loading && <p>加载中...</p>}
+
+      {/* 错误提示 */}
+      {error && <p className="error">{error}</p>}
+
+      {/* 小组列表 */}
+      {!loading && !error && (
+        <div className="group-list">
+          {groups.map((group) => (
+            <div className="group-item" key={group.group_id}>
+              <img
+                src={group.cover_image}
+                alt={group.name}
+                className="group-cover"
+              />
+              <div className="group-info">
+                <h2>{group.name}</h2>
+                <p>{group.description}</p>
+                <p>成员数:{group.member_count}</p>
+                <p>分类:{group.category}</p>
+              </div>
+            </div>
+          ))}
+        </div>
+      )}
+
+      {/* 分页 */}
+      <div className="pagination">
+        <button onClick={() => handlePageChange(page - 1)} disabled={page <= 1}>
+          上一页
+        </button>
+        <span>第 {page} 页 / 共 {totalPages} 页</span>
+        <button
+          onClick={() => handlePageChange(page + 1)}
+          disabled={page >= totalPages}
+        >
+          下一页
+        </button>
+      </div>
+    </div>
+  );
+};
+
+export default InterestGroup;