Header.tsx 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. "use client";
  2. import Link from "next/link";
  3. import { Button } from "@/components/ui/button";
  4. import {
  5. Sheet,
  6. SheetContent,
  7. SheetHeader,
  8. SheetTitle,
  9. SheetTrigger,
  10. SheetClose,
  11. } from "@/components/ui/sheet";
  12. import { Github, Menu } from "lucide-react";
  13. import { websiteConfig } from "@/lib/website-config";
  14. import { LanguageSwitcher } from "@/components/i18n/LanguageSwitcher";
  15. import { useI18n } from "@/lib/i18n/provider";
  16. /**
  17. * 官网顶部导航栏
  18. * 包含 Logo、导航链接和 GitHub 链接
  19. */
  20. export function Header() {
  21. const { t } = useI18n();
  22. return (
  23. <header className="sticky top-0 z-50 w-full border-b border-border/50 bg-background/80 backdrop-blur-md">
  24. <div className="container mx-auto px-6">
  25. <div className="flex h-16 md:h-20 items-center justify-between">
  26. <Link href="/" className="flex items-center gap-2">
  27. <div className="w-9 h-9 rounded-lg bg-primary flex items-center justify-center">
  28. <span className="text-primary-foreground font-semibold text-sm">AI</span>
  29. </div>
  30. <span className="text-[19px] font-semibold text-foreground tracking-tight">AI-CS</span>
  31. </Link>
  32. <div className="flex items-center gap-2 sm:gap-4 md:gap-8">
  33. <Sheet>
  34. <SheetTrigger asChild>
  35. <Button
  36. variant="ghost"
  37. size="icon"
  38. className="md:hidden"
  39. aria-label={t("nav.menu")}
  40. >
  41. <Menu className="w-5 h-5" />
  42. </Button>
  43. </SheetTrigger>
  44. <SheetContent side="right" className="w-[min(100vw-2rem,20rem)]">
  45. <SheetHeader>
  46. <SheetTitle className="text-left">{t("nav.menu")}</SheetTitle>
  47. </SheetHeader>
  48. <nav className="flex flex-col gap-1 mt-8">
  49. <SheetClose asChild>
  50. <Link
  51. href="#features"
  52. className="py-3 text-[15px] text-muted-foreground hover:text-foreground transition-colors border-b border-border/60"
  53. >
  54. {t("nav.features")}
  55. </Link>
  56. </SheetClose>
  57. <SheetClose asChild>
  58. <Link
  59. href="#screenshots"
  60. className="py-3 text-[15px] text-muted-foreground hover:text-foreground transition-colors border-b border-border/60"
  61. >
  62. {t("nav.screenshots")}
  63. </Link>
  64. </SheetClose>
  65. <SheetClose asChild>
  66. <Link
  67. href="#quick-start"
  68. className="py-3 text-[15px] text-muted-foreground hover:text-foreground transition-colors border-b border-border/60"
  69. >
  70. {t("nav.quickStart")}
  71. </Link>
  72. </SheetClose>
  73. <SheetClose asChild>
  74. <Link
  75. href="/agent/login"
  76. target="_blank"
  77. rel="noopener noreferrer"
  78. className="py-3 text-[15px] text-muted-foreground hover:text-foreground transition-colors"
  79. >
  80. {t("nav.agentLogin")}
  81. </Link>
  82. </SheetClose>
  83. </nav>
  84. </SheetContent>
  85. </Sheet>
  86. <nav className="hidden md:flex items-center gap-6">
  87. <Link
  88. href="#features"
  89. className="text-[15px] text-muted-foreground hover:text-foreground transition-colors"
  90. >
  91. {t("nav.features")}
  92. </Link>
  93. <Link
  94. href="#screenshots"
  95. className="text-[15px] text-muted-foreground hover:text-foreground transition-colors"
  96. >
  97. {t("nav.screenshots")}
  98. </Link>
  99. <Link
  100. href="#quick-start"
  101. className="text-[15px] text-muted-foreground hover:text-foreground transition-colors"
  102. >
  103. {t("nav.quickStart")}
  104. </Link>
  105. <Link
  106. href="/agent/login"
  107. target="_blank"
  108. rel="noopener noreferrer"
  109. className="text-[15px] text-muted-foreground hover:text-foreground transition-colors"
  110. >
  111. {t("nav.agentLogin")}
  112. </Link>
  113. </nav>
  114. <LanguageSwitcher variant="ghost" size="sm" className="hidden sm:flex text-muted-foreground hover:text-foreground" />
  115. <Button variant="ghost" size="sm" asChild className="hidden sm:flex text-muted-foreground hover:text-foreground">
  116. <a
  117. href={websiteConfig.github.repo}
  118. target="_blank"
  119. rel="noopener noreferrer"
  120. className="flex items-center gap-2"
  121. >
  122. <Github className="w-4 h-4" />
  123. <span>{t("common.github")}</span>
  124. </a>
  125. </Button>
  126. <Button variant="ghost" size="icon" asChild className="sm:hidden text-muted-foreground hover:text-foreground">
  127. <a
  128. href={websiteConfig.github.repo}
  129. target="_blank"
  130. rel="noopener noreferrer"
  131. aria-label="GitHub"
  132. >
  133. <Github className="w-5 h-5" />
  134. </a>
  135. </Button>
  136. <LanguageSwitcher variant="ghost" size="icon" className="sm:hidden text-muted-foreground hover:text-foreground" />
  137. </div>
  138. </div>
  139. </div>
  140. </header>
  141. );
  142. }