blob: 3456195f2d068583d0640b7fceb5f682d6692b1b [file] [log] [blame]
Krishya2e0f49a2025-05-29 10:59:01 +08001import React from 'react';
2import { Link, useLocation } from 'react-router-dom';
3import './UserNav.css'; // 导入 UserNav 样式文件
4
5const UserNav = () => {
6 const location = useLocation();
7
2230100964011632025-06-04 21:57:22 +08008 // 竖直导航栏的链接项(已添加“新手考核”)
Krishya2e0f49a2025-05-29 10:59:01 +08009 const navLinks = [
10 { to: '/user/profile', label: '个人资料' },
11 { to: '/user/dynamics', label: '我的动态' },
12 { to: '/user/friends', label: '我的好友' },
13 { to: '/user/groups', label: '我的群组' },
14 { to: '/user/collections', label: '我的收藏' },
223010093d8132e2025-06-07 11:34:38 +080015 // { to: '/user/newbie-tasks', label: '新手考核' },
Krishya7096ab12025-06-05 17:15:46 +080016 { to: '/user/invite', label: '邀请新用户' },
Krishya2e0f49a2025-05-29 10:59:01 +080017 ];
18
19 // 判断路径是否是当前活动页面
20 const isActive = (path) => location.pathname.startsWith(path);
21
22 return (
23 <div className="user-nav-container">
24 <nav className="user-nav">
25 {navLinks.map(({ to, label }) => (
26 <Link
27 key={to}
28 to={to}
29 className={`user-nav-item ${isActive(to) ? 'active' : ''}`}
30 >
31 {label}
32 </Link>
33 ))}
34 </nav>
35 </div>
36 );
37};
38
39export default UserNav;