HomePageClient.tsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. "use client";
  2. import { useEffect, useState } from "react";
  3. import Link from "next/link";
  4. import { Button } from "@/components/ui/button";
  5. import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
  6. import {
  7. Bot,
  8. BookOpen,
  9. Users,
  10. Wand2,
  11. LineChart,
  12. ScrollText,
  13. Globe,
  14. LayoutDashboard,
  15. FileText,
  16. ArrowRight,
  17. ChevronLeft,
  18. ChevronRight,
  19. MessageSquare,
  20. Github,
  21. Mail,
  22. } from "lucide-react";
  23. import { ScreenshotDisplay } from "@/components/ScreenshotDisplay";
  24. import { ChatWidget } from "@/components/visitor/ChatWidget";
  25. import { FloatingButton } from "@/components/visitor/FloatingButton";
  26. import { Header } from "@/components/layout/Header";
  27. import { Footer } from "@/components/layout/Footer";
  28. import { FadeIn, FadeInStagger, FadeInItem } from "@/components/ui/fade-in";
  29. import { websiteConfig } from "@/lib/website-config";
  30. import { stats } from "@/lib/stats-config";
  31. import type { I18nKey } from "@/lib/i18n/dict";
  32. import { useI18n } from "@/lib/i18n/provider";
  33. import type { LucideIcon } from "lucide-react";
  34. const CAPABILITY_ITEMS: {
  35. icon: LucideIcon;
  36. titleKey: I18nKey;
  37. descKey: I18nKey;
  38. }[] = [
  39. { icon: Bot, titleKey: "home.cap.multimodel.title", descKey: "home.cap.multimodel.desc" },
  40. { icon: BookOpen, titleKey: "home.cap.kb.title", descKey: "home.cap.kb.desc" },
  41. { icon: Wand2, titleKey: "home.cap.prompt.title", descKey: "home.cap.prompt.desc" },
  42. { icon: Users, titleKey: "home.cap.human.title", descKey: "home.cap.human.desc" },
  43. { icon: LineChart, titleKey: "home.cap.reports.title", descKey: "home.cap.reports.desc" },
  44. { icon: ScrollText, titleKey: "home.cap.logs.title", descKey: "home.cap.logs.desc" },
  45. ];
  46. const QUICK_STEPS: { titleKey: I18nKey; bodyKey: I18nKey }[] = [
  47. { titleKey: "home.step1.title", bodyKey: "home.step1.body" },
  48. { titleKey: "home.step2.title", bodyKey: "home.step2.body" },
  49. { titleKey: "home.step3.title", bodyKey: "home.step3.body" },
  50. ];
  51. const SCREENSHOT_ITEMS: {
  52. slug: string;
  53. imageName: string;
  54. placeholderIcon: LucideIcon;
  55. titleKey: I18nKey;
  56. placeholderKey: I18nKey;
  57. altKey: I18nKey;
  58. }[] = [
  59. {
  60. slug: "dashboard",
  61. imageName: "dashboard.png",
  62. placeholderIcon: LayoutDashboard,
  63. titleKey: "home.ss.dashboard.title",
  64. placeholderKey: "home.ss.dashboard.placeholder",
  65. altKey: "home.ss.dashboard.alt",
  66. },
  67. {
  68. slug: "visitor",
  69. imageName: "visitor.png",
  70. placeholderIcon: Globe,
  71. titleKey: "home.ss.visitor.title",
  72. placeholderKey: "home.ss.visitor.placeholder",
  73. altKey: "home.ss.visitor.alt",
  74. },
  75. {
  76. slug: "ai-config",
  77. imageName: "ai-config.png",
  78. placeholderIcon: Bot,
  79. titleKey: "home.ss.aiconfig.title",
  80. placeholderKey: "home.ss.aiconfig.placeholder",
  81. altKey: "home.ss.aiconfig.alt",
  82. },
  83. {
  84. slug: "users",
  85. imageName: "users.png",
  86. placeholderIcon: Users,
  87. titleKey: "home.ss.users.title",
  88. placeholderKey: "home.ss.users.placeholder",
  89. altKey: "home.ss.users.alt",
  90. },
  91. {
  92. slug: "faq",
  93. imageName: "faq.png",
  94. placeholderIcon: FileText,
  95. titleKey: "home.ss.faq.title",
  96. placeholderKey: "home.ss.faq.placeholder",
  97. altKey: "home.ss.faq.alt",
  98. },
  99. {
  100. slug: "knowledge",
  101. imageName: "knowledge.png",
  102. placeholderIcon: BookOpen,
  103. titleKey: "home.ss.knowledge.title",
  104. placeholderKey: "home.ss.knowledge.placeholder",
  105. altKey: "home.ss.knowledge.alt",
  106. },
  107. {
  108. slug: "conversations",
  109. imageName: "conversations.png",
  110. placeholderIcon: MessageSquare,
  111. titleKey: "home.ss.kbtest.title",
  112. placeholderKey: "home.ss.kbtest.placeholder",
  113. altKey: "home.ss.kbtest.alt",
  114. },
  115. {
  116. slug: "prompts",
  117. imageName: "prompts.png",
  118. placeholderIcon: Wand2,
  119. titleKey: "home.ss.prompts.title",
  120. placeholderKey: "home.ss.prompts.placeholder",
  121. altKey: "home.ss.prompts.alt",
  122. },
  123. {
  124. slug: "logs",
  125. imageName: "logs.png",
  126. placeholderIcon: ScrollText,
  127. titleKey: "home.ss.logs.title",
  128. placeholderKey: "home.ss.logs.placeholder",
  129. altKey: "home.ss.logs.alt",
  130. },
  131. {
  132. slug: "analytics",
  133. imageName: "analytics.png",
  134. placeholderIcon: LineChart,
  135. titleKey: "home.ss.analytics.title",
  136. placeholderKey: "home.ss.analytics.placeholder",
  137. altKey: "home.ss.analytics.alt",
  138. },
  139. ];
  140. export function HomePageClient() {
  141. const { t } = useI18n();
  142. const [visitorId, setVisitorId] = useState<number | null>(null);
  143. const [isChatOpen, setIsChatOpen] = useState(false);
  144. const [activeScreenshot, setActiveScreenshot] = useState(0);
  145. useEffect(() => {
  146. let stored = window.localStorage.getItem("visitor_id");
  147. if (!stored) {
  148. stored = `${Date.now()}${Math.floor(Math.random() * 100000)}`;
  149. window.localStorage.setItem("visitor_id", stored);
  150. }
  151. const parsed = Number.parseInt(stored, 10);
  152. setVisitorId(Number.isNaN(parsed) ? null : parsed);
  153. }, []);
  154. const handleToggleChat = () => setIsChatOpen((prev) => !prev);
  155. const handleOpenChat = () => {
  156. if (visitorId === null) {
  157. setTimeout(() => setIsChatOpen(true), 500);
  158. } else {
  159. setIsChatOpen(true);
  160. }
  161. };
  162. const totalScreenshots = SCREENSHOT_ITEMS.length;
  163. const prevScreenshotIndex =
  164. (activeScreenshot - 1 + totalScreenshots) % totalScreenshots;
  165. const nextScreenshotIndex = (activeScreenshot + 1) % totalScreenshots;
  166. const goPrevScreenshot = () => {
  167. setActiveScreenshot((prev) => (prev - 1 + totalScreenshots) % totalScreenshots);
  168. };
  169. const goNextScreenshot = () => {
  170. setActiveScreenshot((prev) => (prev + 1) % totalScreenshots);
  171. };
  172. useEffect(() => {
  173. const timer = window.setInterval(() => {
  174. setActiveScreenshot((prev) => (prev + 1) % totalScreenshots);
  175. }, 4800);
  176. return () => window.clearInterval(timer);
  177. }, [totalScreenshots]);
  178. return (
  179. <div className="min-h-screen bg-background text-foreground">
  180. <Header />
  181. {/* Hero(回归旧版文案气质,保留新版三按钮) */}
  182. <section className="relative overflow-hidden border-b border-border/40">
  183. <div
  184. className="pointer-events-none absolute inset-0 bg-[radial-gradient(120%_80%_at_50%_-20%,rgba(37,99,235,0.14),transparent_55%)]"
  185. aria-hidden
  186. />
  187. <div
  188. className="pointer-events-none absolute inset-0 bg-gradient-to-b from-blue-50/80 via-background to-background"
  189. aria-hidden
  190. />
  191. <div className="container relative mx-auto px-6 pb-32 pt-20 md:pb-40 md:pt-28 lg:pt-28 xl:max-w-[1280px]">
  192. <FadeIn>
  193. <div className="mx-auto max-w-4xl text-center">
  194. <p className="mb-4 text-sm font-medium text-muted-foreground tracking-wide uppercase">
  195. {t("home.hero.tagline")}
  196. </p>
  197. <h1 className="mb-6 text-balance text-4xl font-bold tracking-tight text-foreground sm:text-5xl md:text-6xl md:leading-[1.12]">
  198. {t("home.hero.title")}
  199. </h1>
  200. <p className="mx-auto mb-10 max-w-3xl text-pretty text-lg sm:text-xl text-muted-foreground leading-relaxed">
  201. {t("home.hero.subtitle")}
  202. </p>
  203. <div className="flex flex-col items-stretch justify-center gap-3 sm:flex-row sm:flex-wrap sm:items-center">
  204. <Button
  205. size="lg"
  206. className="rounded-xl bg-blue-600 px-8 py-6 text-[15px] shadow-sm transition-all hover:bg-blue-500 hover:shadow-md"
  207. onClick={handleOpenChat}
  208. >
  209. {t("home.hero.cta.tryNow")}
  210. <ArrowRight className="ml-2 h-4 w-4" />
  211. </Button>
  212. <Button
  213. size="lg"
  214. variant="outline"
  215. className="rounded-xl border-border/80 px-8 py-6 text-[15px] bg-background/60 backdrop-blur-sm"
  216. asChild
  217. >
  218. <Link
  219. href="/agent/login"
  220. target="_blank"
  221. rel="noopener noreferrer"
  222. className="inline-flex items-center justify-center gap-2"
  223. >
  224. {t("home.hero.cta.agentLogin")}
  225. </Link>
  226. </Button>
  227. </div>
  228. <p className="mt-4 text-sm text-muted-foreground">{t("home.hero.hint")}</p>
  229. </div>
  230. </FadeIn>
  231. </div>
  232. </section>
  233. {/* 数字条(沿用旧版) */}
  234. <section className="py-16 md:py-20 border-t border-border/50">
  235. <FadeIn>
  236. <div className="container mx-auto px-6">
  237. <p className="text-xs font-medium text-muted-foreground text-center mb-8 tracking-wide">
  238. {t("home.stats.trustedBy")}
  239. </p>
  240. <div className="grid grid-cols-2 md:grid-cols-4 gap-10 max-w-6xl mx-auto">
  241. {stats.map((stat) => (
  242. <div key={stat.labelKey} className="text-center">
  243. <div className="text-3xl md:text-4xl font-semibold text-foreground">
  244. {t(stat.valueKey)}
  245. </div>
  246. <div className="mt-1 text-sm text-muted-foreground">{t(stat.labelKey)}</div>
  247. </div>
  248. ))}
  249. </div>
  250. </div>
  251. </FadeIn>
  252. </section>
  253. {/* 核心能力 */}
  254. <section id="features" className="relative scroll-mt-20">
  255. <div className="pointer-events-none absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-blue-200/50 to-transparent" aria-hidden />
  256. <div className="container mx-auto px-6 py-20 md:py-28">
  257. <FadeIn>
  258. <div className="mb-14 text-center px-4">
  259. <h2 className="mb-3 text-3xl font-semibold tracking-tight text-foreground sm:text-4xl">
  260. {t("home.features.title")}
  261. </h2>
  262. <p className="mx-auto max-w-xl text-base text-muted-foreground">
  263. {t("home.features.lead")}
  264. </p>
  265. </div>
  266. </FadeIn>
  267. <FadeInStagger className="mx-auto grid max-w-6xl grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3 lg:gap-6">
  268. {CAPABILITY_ITEMS.map((item) => {
  269. const Icon = item.icon;
  270. return (
  271. <FadeInItem key={item.titleKey}>
  272. <Card className="group h-full border border-border/60 bg-card/90 shadow-sm backdrop-blur-sm transition-all duration-300 hover:-translate-y-0.5 hover:border-blue-200/70 hover:shadow-md">
  273. <CardHeader className="pb-3">
  274. <div className="mb-4 flex h-11 w-11 items-center justify-center rounded-xl border border-blue-100/80 bg-gradient-to-br from-blue-50 to-background text-blue-700 transition-transform duration-300 group-hover:scale-[1.03]">
  275. <Icon className="h-5 w-5" />
  276. </div>
  277. <CardTitle className="text-lg font-semibold tracking-tight">
  278. {t(item.titleKey)}
  279. </CardTitle>
  280. <CardDescription className="text-sm leading-relaxed text-muted-foreground">
  281. {t(item.descKey)}
  282. </CardDescription>
  283. </CardHeader>
  284. </Card>
  285. </FadeInItem>
  286. );
  287. })}
  288. </FadeInStagger>
  289. </div>
  290. </section>
  291. {/* 界面展示 */}
  292. <FadeIn>
  293. <section
  294. id="screenshots"
  295. className="scroll-mt-20 border-t border-border/40 bg-muted/20 py-20 md:py-28"
  296. >
  297. <div className="container mx-auto px-6">
  298. <div className="mb-14 text-center px-4">
  299. <h2 className="mb-3 text-3xl font-semibold tracking-tight sm:text-4xl">
  300. {t("home.screenshots.title")}
  301. </h2>
  302. <p className="mx-auto max-w-xl text-muted-foreground">
  303. {t("home.screenshots.lead")}
  304. </p>
  305. </div>
  306. <div className="mx-auto max-w-6xl">
  307. <div className="mb-8 flex flex-wrap justify-center gap-2">
  308. {SCREENSHOT_ITEMS.map((item, idx) => (
  309. <button
  310. key={item.slug}
  311. type="button"
  312. onClick={() => setActiveScreenshot(idx)}
  313. className={`rounded-full px-4 py-1.5 text-sm transition-all ${
  314. idx === activeScreenshot
  315. ? "bg-blue-600 text-white shadow-sm"
  316. : "bg-background text-muted-foreground border border-border/70 hover:text-foreground hover:border-blue-200"
  317. }`}
  318. >
  319. {t(item.titleKey)}
  320. </button>
  321. ))}
  322. </div>
  323. <div className="relative mx-auto max-w-6xl px-4 md:px-8">
  324. <div className="pointer-events-none absolute inset-0 -z-10 bg-[radial-gradient(80%_60%_at_50%_40%,rgba(37,99,235,0.14),transparent_70%)]" />
  325. <div className="relative h-[290px] md:h-[420px] lg:h-[510px]">
  326. <button
  327. type="button"
  328. onClick={goPrevScreenshot}
  329. className="absolute left-0 top-1/2 z-40 -translate-y-1/2 rounded-full border border-border/70 bg-background/90 p-2.5 shadow-sm backdrop-blur transition hover:border-blue-200 hover:bg-background"
  330. aria-label={t("home.screenshots.prevAria")}
  331. >
  332. <ChevronLeft className="h-5 w-5" />
  333. </button>
  334. <button
  335. type="button"
  336. onClick={goNextScreenshot}
  337. className="absolute right-0 top-1/2 z-40 -translate-y-1/2 rounded-full border border-border/70 bg-background/90 p-2.5 shadow-sm backdrop-blur transition hover:border-blue-200 hover:bg-background"
  338. aria-label={t("home.screenshots.nextAria")}
  339. >
  340. <ChevronRight className="h-5 w-5" />
  341. </button>
  342. {/* 左侧半露卡片 */}
  343. <div className="absolute left-6 right-[42%] top-7 z-10 hidden overflow-hidden rounded-2xl border border-border/60 bg-background/85 shadow-md md:block">
  344. <div className="pointer-events-none absolute inset-0 z-10 bg-background/18" />
  345. <ScreenshotDisplay
  346. imageName={SCREENSHOT_ITEMS[prevScreenshotIndex].imageName}
  347. placeholderIcon={SCREENSHOT_ITEMS[prevScreenshotIndex].placeholderIcon}
  348. placeholderText={t(SCREENSHOT_ITEMS[prevScreenshotIndex].placeholderKey)}
  349. alt={t(SCREENSHOT_ITEMS[prevScreenshotIndex].altKey)}
  350. />
  351. </div>
  352. {/* 右侧半露卡片 */}
  353. <div className="absolute left-[42%] right-6 top-7 z-10 hidden overflow-hidden rounded-2xl border border-border/60 bg-background/85 shadow-md md:block">
  354. <div className="pointer-events-none absolute inset-0 z-10 bg-background/18" />
  355. <ScreenshotDisplay
  356. imageName={SCREENSHOT_ITEMS[nextScreenshotIndex].imageName}
  357. placeholderIcon={SCREENSHOT_ITEMS[nextScreenshotIndex].placeholderIcon}
  358. placeholderText={t(SCREENSHOT_ITEMS[nextScreenshotIndex].placeholderKey)}
  359. alt={t(SCREENSHOT_ITEMS[nextScreenshotIndex].altKey)}
  360. />
  361. </div>
  362. {/* 中间主卡片 */}
  363. <div className="absolute inset-x-8 top-0 z-30 overflow-hidden rounded-2xl border border-border/70 bg-background shadow-xl ring-1 ring-blue-100/60 md:inset-x-16 lg:inset-x-24">
  364. <ScreenshotDisplay
  365. imageName={SCREENSHOT_ITEMS[activeScreenshot].imageName}
  366. placeholderIcon={SCREENSHOT_ITEMS[activeScreenshot].placeholderIcon}
  367. placeholderText={t(SCREENSHOT_ITEMS[activeScreenshot].placeholderKey)}
  368. alt={t(SCREENSHOT_ITEMS[activeScreenshot].altKey)}
  369. />
  370. </div>
  371. </div>
  372. </div>
  373. </div>
  374. </div>
  375. </section>
  376. </FadeIn>
  377. {/* 快速接入 */}
  378. <section id="quick-start" className="relative scroll-mt-20 border-t border-border/40">
  379. <div
  380. className="pointer-events-none absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-border to-transparent"
  381. aria-hidden
  382. />
  383. <div className="container mx-auto px-6 py-20 md:py-28">
  384. <FadeIn>
  385. <div className="mb-12 text-center px-4">
  386. <h2 className="mb-3 text-3xl font-semibold tracking-tight sm:text-4xl">
  387. {t("home.quickStart.title")}
  388. </h2>
  389. <p className="text-muted-foreground">{t("home.quickStart.lead")}</p>
  390. </div>
  391. </FadeIn>
  392. <FadeInStagger className="mx-auto grid max-w-4xl grid-cols-1 gap-8 md:grid-cols-3">
  393. {QUICK_STEPS.map((step, i) => (
  394. <FadeInItem key={step.titleKey}>
  395. <div className="relative rounded-2xl border border-border/60 bg-card/50 p-6 text-center md:text-left transition-all duration-300 hover:border-blue-200/70 hover:shadow-md hover:-translate-y-0.5">
  396. <div className="mx-auto mb-4 flex h-10 w-10 items-center justify-center rounded-full border border-blue-200/80 bg-blue-50/80 text-sm font-semibold text-blue-800 md:mx-0">
  397. {i + 1}
  398. </div>
  399. <h3 className="mb-2 font-semibold">{t(step.titleKey)}</h3>
  400. <p className="text-sm leading-relaxed text-muted-foreground">{t(step.bodyKey)}</p>
  401. </div>
  402. </FadeInItem>
  403. ))}
  404. </FadeInStagger>
  405. </div>
  406. </section>
  407. {/* 收尾 CTA */}
  408. <section className="relative border-t border-border/40 overflow-hidden">
  409. <div
  410. className="pointer-events-none absolute inset-0 bg-gradient-to-br from-blue-600/[0.07] via-transparent to-blue-400/[0.06]"
  411. aria-hidden
  412. />
  413. <div className="container relative mx-auto px-6 py-20 text-center md:py-28">
  414. <FadeIn>
  415. <h2 className="mb-4 text-3xl font-semibold tracking-tight sm:text-4xl">
  416. {t("home.cta.title")}
  417. </h2>
  418. <p className="mx-auto mb-10 max-w-lg text-muted-foreground leading-relaxed">
  419. {t("home.cta.subtitle")}
  420. </p>
  421. <div className="flex flex-col items-stretch justify-center gap-3 sm:flex-row sm:flex-wrap sm:justify-center">
  422. <Button size="lg" className="rounded-xl bg-blue-600 px-8 shadow-sm hover:bg-blue-500" asChild>
  423. <a
  424. href={websiteConfig.github.repo}
  425. target="_blank"
  426. rel="noopener noreferrer"
  427. className="inline-flex items-center justify-center gap-2"
  428. >
  429. <Github className="h-4 w-4" />
  430. {t("home.cta.starRepo")}
  431. </a>
  432. </Button>
  433. <Button size="lg" variant="outline" className="rounded-xl border-border/80 px-8 bg-background/80" asChild>
  434. <a
  435. href={`mailto:2930134478@qq.com?subject=${encodeURIComponent(t("home.cta.mailSubject"))}&body=${encodeURIComponent(t("home.cta.mailBody"))}`}
  436. className="inline-flex items-center justify-center gap-2"
  437. >
  438. {t("home.cta.feedback")}
  439. <Mail className="h-3.5 w-3.5" />
  440. </a>
  441. </Button>
  442. </div>
  443. </FadeIn>
  444. </div>
  445. </section>
  446. <Footer />
  447. {visitorId !== null && (
  448. <>
  449. <FloatingButton onClick={handleToggleChat} isOpen={isChatOpen} />
  450. {isChatOpen && (
  451. <ChatWidget visitorId={visitorId} isOpen={isChatOpen} onToggle={handleToggleChat} />
  452. )}
  453. </>
  454. )}
  455. </div>
  456. );
  457. }