import React, { useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { Link, useNavigate, useLocation } from 'react-router-dom'; import { logoutThunk } from '../store/auth/auth.thunk'; import UserSettingsModal from '../components/UserSettingsModal'; import NotificationCenter from '../components/NotificationCenter'; import SvgIcon from '../components/SvgIcon'; export default function HeaderWithNav() { const dispatch = useDispatch(); const navigate = useNavigate(); const location = useLocation(); const { user } = useSelector((state) => state.auth); const [showSettings, setShowSettings] = useState(false); const [showNotifications, setShowNotifications] = useState(false); const { notifications } = useSelector((state) => state.notificationCenter); const handleLogout = async () => { try { await dispatch(logoutThunk()).unwrap(); sessionStorage.removeItem('token'); navigate('/login'); } catch (error) {} }; // Check if the current path starts with the given path const isActive = (path) => { return location.pathname.startsWith(path); }; console.log('user', user); // 检查用户是否有管理权限(leader 或 admin) const hasManagePermission = user && (user.role === 'leader' || user.role === 'admin'); return (
setShowSettings(false)} /> setShowNotifications(false)} />
); }