/** * 首页主体:薄 SSR — Astro 壳负责 head/导航,本组件在浏览器渲染。 */ import { t, type Locale } from "@app/i18n"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { useState } from "react"; import { go } from "~/lib/nav"; import { createTRPCReactClient, trpc } from "~/lib/trpc"; export interface HomeBodyProps { locale: Locale; } function ContinueStrip(props: { locale: Locale }) { const { locale } = props; const list = trpc.media.playbackContinue.useQuery({ limit: 4 }, { retry: false }); const items = list.data ?? []; if (items.length === 0) return null; return ( {t(locale, "library.continueTitle")} {items.map((item) => ( go(`/${locale}/watch?id=${item.mediaItemId}`)} > {item.title} ))} ); } function HomeInner({ locale }: HomeBodyProps) { const tr = (key: Parameters[1]) => t(locale, key); const libraryHref = locale === "zh-CN" ? "/zh-CN/library" : "/en/library"; const loginHref = locale === "zh-CN" ? "/zh-CN/auth/login" : "/en/auth/login"; const me = trpc.auth.me.useQuery(undefined, { retry: false }); const loggedIn = me.data?.user != null; const steps = [ { key: "nav.mounts", href: `/${locale}/mounts` }, { key: "nav.browse", href: `/${locale}/browse` }, { key: "nav.library", href: `/${locale}/library` }, { key: "nav.danmaku", href: `/${locale}/danmaku` }, ] as const; return ( {tr("meta.tagline")} {tr("home.heroLine1")} {tr("home.heroLine2")} {tr("home.subtitle")} {tr("home.ctaDashboard")} {!loggedIn && ( {tr("home.ctaLogin")} )} {tr("home.stackTitle")} {tr("home.stackBody")} {tr("home.layerTitle")} {tr("home.layerBody")} {steps.map((s, i) => ( {String(i + 1).padStart(2, "0")} {tr(s.key)} ))} ); } const trpcClient = createTRPCReactClient(); export default function HomeBody({ locale }: HomeBodyProps) { const [qc] = useState(() => new QueryClient()); return ( ); }
{t(locale, "library.continueTitle")}
{tr("meta.tagline")}
{tr("home.subtitle")}
{tr("home.stackTitle")}
{tr("home.stackBody")}
{tr("home.layerTitle")}
{tr("home.layerBody")}