import { createFileRoute, Link, useNavigate } from "@tanstack/react-router";
import { motion } from "framer-motion";
import { useEffect, useRef, useState } from "react";
import { ArrowRight, ChevronDown, Compass, Sparkles } from "lucide-react";
import heroEye from "@/assets/hero-eye.jpg";
import kidsForest from "@/assets/kids-forest.jpg";
import { ELEMENTS } from "@/data/elements";
import { Particles } from "@/components/Particles";
import { EyeDiagram } from "@/components/EyeDiagram";
import { Button } from "@/components/ui/button";
import { useProgress } from "@/lib/progress";
import { cn } from "@/lib/utils";
export const Route = createFileRoute("/")({
head: () => ({
meta: [
{ title: "目之世界 · 一眼观万象,寻迹五脏六腑" },
{ name: "description", content: "北京杏园金方国医医院中医眼健康沉浸式科普:探索眼睛的奥秘,开启一场中医奇幻之旅。" },
{ property: "og:title", content: "目之世界 · THE WORLD OF EYES" },
{ property: "og:description", content: "一眼观万象,寻迹五脏六腑——探索眼睛的奥秘,开启一场中医奇幻之旅。" },
{ property: "og:type", content: "website" },
{ name: "twitter:card", content: "summary_large_image" },
],
}),
component: Home,
});
/* Iris centre & radius as fractions of the 1920×1088 artwork */
const IMG_W = 1920;
const IMG_H = 1088;
const IRIS = { x: 0.5286, y: 0.2344, r: 0.125 };
interface Layout {
w: number;
h: number;
left: number;
top: number;
ix: number;
iy: number;
ir: number;
H: number;
}
function useHeroLayout(ref: React.RefObject
) {
const [layout, setLayout] = useState(null);
useEffect(() => {
const el = ref.current;
if (!el) return;
const compute = () => {
const W = el.clientWidth;
const H = el.clientHeight;
const s = Math.max(W / IMG_W, H / IMG_H);
const w = IMG_W * s;
const h = IMG_H * s;
const left = Math.min(0, Math.max(W - w, W / 2 - IRIS.x * w));
const top = Math.min(0, Math.max(H - h, H * 0.3 - IRIS.y * h));
setLayout({ w, h, left, top, ix: left + IRIS.x * w, iy: top + IRIS.y * h, ir: IRIS.r * w, H });
};
compute();
const ro = new ResizeObserver(compute);
ro.observe(el);
return () => ro.disconnect();
}, [ref]);
return layout;
}
function Hero() {
const ref = useRef(null);
const layout = useHeroLayout(ref);
const navigate = useNavigate();
const [entering, setEntering] = useState(false);
const enter = () => {
if (entering) return;
setEntering(true);
window.setTimeout(() => navigate({ to: "/worlds" }), 1150);
};
const eyeY = layout ? `${(layout.iy / layout.H) * 100}%` : "28%";
const reveal = (delay: number) => ({
initial: { opacity: 0, y: 24, filter: "blur(8px)" },
animate: { opacity: 1, y: 0, filter: "blur(0px)" },
transition: { duration: 1.2, delay, ease: [0.2, 0.7, 0.2, 1] as const },
});
return (
{/* closed-eye slit glow */}
{layout && (
<>
>
)}
{/* entering flash */}
北京杏园金方国医医院 · 中医眼健康奇幻之旅
目之世界
The World of Eyes
一眼观万象,寻迹五脏六腑
探索眼睛的奥秘,开启一场中医奇幻之旅
先看看五行地图
);
}
function FiveElements() {
const { discoveries } = useProgress();
return (
Five Elements · Five Realms
五行秘境
木、火、土、金、水——中医以五行之象类比五脏。穿越五片奇境,认识传统理论中眼睛与身体的整体关联。
{ELEMENTS.map((el, i) => {
const found = el.discoveries.filter((d) => discoveries.includes(d.id)).length;
return (
{el.char}
{el.name}
{el.tagline}
{el.discoveries.map((d) => (
))}
{found}/{el.discoveries.length} 已发现
);
})}
);
}
function Paths() {
const rows = [
{
kicker: "Anatomy of the Eye",
title: "眼之构造",
text: "从眼睑到视神经,点亮七处结构,读懂现代解剖、常见问题、中医视角与就医时机。",
to: "/anatomy" as const,
cta: "进入解剖图鉴",
visual: (
),
},
{
kicker: "Bright Eyes for Young Explorers",
title: "少年明眸计划",
text: "跟着小鹿明明与猫头鹰博博走进星光森林,认识近视、假性近视与远视储备,再挑战一场亲子小测验。",
to: "/children" as const,
cta: "走进星光森林",
visual: (
),
},
{
kicker: "Eye Wellness Self-check",
title: "护眼自测",
text: "八个问题,生成一份专属的眼健康科普报告与分享海报。本地运行的教育模拟,不是诊断。",
to: "/check" as const,
cta: "开始自测",
visual: (
{["用眼舒适度", "生活建议", "检查提醒"].map((t, i) => (
{t}
))}
明
),
},
];
return (
{rows.map((r, i) => (
{r.visual}
0{i + 1} · {r.kicker}
{r.title}
{r.text}
))}
);
}
function Closing() {
return (
收集你的探索足迹
每一次发现都会被记录。完成探索后,生成一张属于你的国风海报,分享给家人朋友。
);
}
function Home() {
return (
<>
>
);
}