import { Avatar, Menu, Dropdown } from "antd"; import { LogoutOutlined, SettingOutlined, UserAddOutlined, UserSwitchOutlined, } from "@ant-design/icons"; import { useAuth } from "@web/src/providers/auth-provider"; import { useNavigate } from "react-router-dom"; export const UserMenu = () => { const { isAuthenticated, logout, user } = useAuth(); const navigate = useNavigate(); return ( {isAuthenticated ? ( <>
{(user?.showname || user?.username || "")[0]?.toUpperCase()}
{user?.showname || user?.username} {user?.department?.name || user?.officerId}
} className="px-4"> 个人设置 } onClick={() => { navigate("/admin/staff"); }} className="px-4"> 后台管理 } onClick={async () => await logout()} className="px-4 text-red-500 hover:text-red-600 hover:bg-red-50"> 退出登录 ) : ( navigate("/login")} className="px-4 text-blue-500 hover:text-blue-600 hover:bg-blue-50"> 登录/注册 )}
); };