create-seed-detail
Change-Id: I7dcce81a7510b6fa97781d3ce509a8dc2ac229d4
diff --git a/src/components/Header.css b/src/components/Header.css
new file mode 100644
index 0000000..5d60638
--- /dev/null
+++ b/src/components/Header.css
@@ -0,0 +1,42 @@
+.header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: 10px;
+ }
+ .logo-and-name {
+ display: flex;
+ align-items: center;
+ }
+ .logo {
+ height: 30px;
+ margin-right: 10px;
+ }
+ .site-name {
+ font-size: 24px;
+ }
+ .user-and-message {
+ display: flex;
+ align-items: center;
+ }
+ .user-avatar {
+ height: 40px;
+ margin-right: 10px;
+ }
+ .message-center {
+ font-size: 16px;
+ }
+ .nav {
+ background-color: #dab8c2;
+ display: flex;
+ justify-content: center;
+ }
+ .nav-item {
+ color: white;
+ text-decoration: none;
+ padding: 10px 20px;
+ }
+ .active {
+ background-color: #996633;
+ }
+
\ No newline at end of file
diff --git a/src/components/Header.jsx b/src/components/Header.jsx
new file mode 100644
index 0000000..79a3086
--- /dev/null
+++ b/src/components/Header.jsx
@@ -0,0 +1,39 @@
+import React from 'react';
+import { Link, useLocation } from 'react-router-dom'; // 引入 useLocation 钩子
+import './Header.css'; // 导入 Header.css 文件
+import logo from '../assets/logo.png';
+
+const Header = () => {
+ const location = useLocation(); // 获取当前路径
+
+ // 判断路径是否是种子列表相关
+ const isSeedListActive = location.pathname.startsWith('/seed-list') || location.pathname.startsWith('/seed/');
+
+ return (
+ <div className="main-page">
+ {/* 顶部栏 */}
+ <header className="header">
+ {/* 左侧 logo 和网站名称 */}
+ <div className="logo-and-name">
+ <img src={logo} alt="网站 logo" className="logo" />
+ <span className="site-name">Echo</span>
+ </div>
+ {/* 右侧用户头像和消息中心 */}
+ <div className="user-and-message">
+ <img src="user-avatar.png" alt="用户头像" className="user-avatar" />
+ <span className="message-center">消息</span>
+ </div>
+ </header>
+ {/* 导航栏 */}
+ <nav className="nav">
+ <Link to="/friend-moments" className="nav-item">好友动态</Link>
+ <Link to="/forum" className="nav-item">论坛</Link>
+ <Link to="/interest-groups" className="nav-item">兴趣小组</Link>
+ <Link to="/seed-list" className={`nav-item ${isSeedListActive ? 'active' : ''}`}>种子列表</Link> {/* 动态添加 active 类 */}
+ <Link to="/publish-seed" className="nav-item">发布种子</Link>
+ </nav>
+ </div>
+ );
+};
+
+export default Header;