| import React from 'react'; |
| import { Link, useLocation } from 'react-router-dom'; |
| import './UserNav.css'; // 导入 UserNav 样式文件 |
| const location = useLocation(); |
| { to: '/user/profile', label: '个人资料' }, |
| { to: '/user/dynamics', label: '我的动态' }, |
| { to: '/user/friends', label: '我的好友' }, |
| { to: '/user/groups', label: '我的群组' }, |
| { to: '/user/collections', label: '我的收藏' }, |
| const isActive = (path) => location.pathname.startsWith(path); |
| <div className="user-nav-container"> |
| <nav className="user-nav"> |
| {navLinks.map(({ to, label }) => ( |
| className={`user-nav-item ${isActive(to) ? 'active' : ''}`} |