DashboardHeader.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use client";
  2. import { getAvatarUrl, getAvatarColor, getAvatarInitial } from "@/utils/avatar";
  3. import { Button } from "@/components/ui/button";
  4. import { Separator } from "@/components/ui/separator";
  5. interface DashboardHeaderProps {
  6. username: string;
  7. role: string;
  8. avatarUrl?: string | null;
  9. onLogout: () => void;
  10. onProfileClick: () => void;
  11. }
  12. export function DashboardHeader({
  13. username,
  14. role,
  15. avatarUrl,
  16. onLogout,
  17. onProfileClick,
  18. }: DashboardHeaderProps) {
  19. // 根据用户名生成头像颜色(如果没有上传头像)
  20. const avatarColor = getAvatarColor(username);
  21. const displayInitial = getAvatarInitial(username);
  22. const fullAvatarUrl = getAvatarUrl(avatarUrl);
  23. return (
  24. <div className="h-16 flex items-center justify-between px-6 bg-background flex-shrink-0 relative">
  25. <div className="flex items-center gap-3 z-10">
  26. <div>
  27. <div className="text-sm text-muted-foreground">当前账号</div>
  28. <div className="text-base font-semibold text-foreground">
  29. {username || "客服"}
  30. {role ? `(${role})` : ""}
  31. </div>
  32. </div>
  33. </div>
  34. <Separator className="absolute bottom-0 left-0 right-0" />
  35. </div>
  36. );
  37. }