import { Component, lazy, Suspense, useEffect, useRef, useState, type ReactNode } from "react"; import { Button, ConfigProvider, Select, Tabs } from "antd"; import { ArrowDown, ArrowRight, ArrowUpRight, Code2, Menu, Pause, Play, X } from "lucide-react"; import { BrandLogo } from "@/components/brand/brand-logo"; import { IconButton } from "@/components/ui/base/buttons"; import { getAntThemeConfig } from "@/lib/app-theme"; import { useAppearanceStore } from "@/stores/use-appearance-store"; import { WelcomeContributorsCard } from "./contributors-card"; import { chapters, getWelcomeLook, showcases, welcomeLooks, type WelcomeLook } from "./story"; import "./welcome.css"; const StoryReel = lazy(() => import("./story-reel")); const github = "https://github.com/ddcat-ai/open-ai-canvas"; export default function WelcomePage() { const [look, setLook] = useState(getWelcomeLook); const appearance = useAppearanceStore((state) => state.appearance); const restorePickerFocus = useRef(false); useEffect(() => { if (!restorePickerFocus.current) return; document.getElementById("welcome-look-select")?.focus({ preventScroll: true }); restorePickerFocus.current = false; }, [look]); useEffect(() => { const onHistory = () => setLook(getWelcomeLook()); window.addEventListener("popstate", onHistory); return () => window.removeEventListener("popstate", onHistory); }, []); const changeLook = (id: string) => { const next = welcomeLooks.find((item) => item.id === id); if (!next || next.id === look.id) return; const url = new URL(window.location.href); url.searchParams.set("look", id); window.history.pushState(null, "", url); restorePickerFocus.current = true; setLook(next); }; return ( ); } function WelcomeExperience({ look, brandName, onLookChange }: { look: WelcomeLook; brandName: string; onLookChange: (id: string) => void }) { const storyRef = useRef(null); const progressRef = useRef(0); const [chapter, setChapter] = useState(0); const [reduced, setReduced] = useState(() => window.matchMedia("(prefers-reduced-motion: reduce)").matches); const [paused, setPaused] = useState(false); const [failed, setFailed] = useState(false); const [ready, setReady] = useState(false); const [menu, setMenu] = useState(false); const [showcase, setShowcase] = useState(1); const [playing, setPlaying] = useState(false); const videoRef = useRef(null); useEffect(() => { document.title = "影策 · 让一个故事从文字走向银幕"; const media = window.matchMedia("(prefers-reduced-motion: reduce)"); const onMotion = () => setReduced(media.matches); media.addEventListener("change", onMotion); const onScroll = () => { if (!storyRef.current) return; const rect = storyRef.current.getBoundingClientRect(); const progress = Math.max(0, Math.min(1, -rect.top / (rect.height - window.innerHeight))); progressRef.current = progress; storyRef.current.style.setProperty("--story-progress", String(progress)); setChapter(Math.min(5, Math.floor(progress * 6))); }; window.addEventListener("scroll", onScroll, { passive: true }); window.addEventListener("resize", onScroll); onScroll(); return () => { media.removeEventListener("change", onMotion); window.removeEventListener("scroll", onScroll); window.removeEventListener("resize", onScroll); }; }, []); useEffect(() => { if (!playing) return; const close = (event: KeyboardEvent) => { if (event.key === "Escape") setPlaying(false); }; window.addEventListener("keydown", close); return () => window.removeEventListener("keydown", close); }, [playing]); const jumpTo = (index: number) => { if (!storyRef.current) return; const height = storyRef.current.offsetHeight - window.innerHeight; window.scrollTo({ top: storyRef.current.offsetTop + height * (index === 5 ? 0.97 : index / 6 + (index ? 0.04 : 0)), behavior: reduced ? "instant" : "smooth" }); setMenu(false); }; const staticScene = reduced || failed; const active = showcases[showcase]; return (
前往工作台介绍
} /> {brandName} setMenu(!menu)} />