Files
web_hghl_h5/src/components/short-drama/short-drama-page.tsx
T
2026-10-28 17:07:32 +07:00

160 lines
6.6 KiB
TypeScript

import { ChannelHeader, H5ChannelHeader } from "@/components/common/channel-header";
import { EmptyState } from "@/components/common/empty-state";
import { FilterChipLink, FilterOptionLink } from "@/components/common/filter-link";
import { Pagination } from "@/components/common/pagination";
import { buildPageHrefMap } from "@/components/common/pagination-map";
import { FloatingActions } from "@/components/home/floating-actions";
import { H5SectionHeading } from "@/components/home/h5-cards";
import { DownloadBanner } from "@/components/home/page-sections";
import { SeoBreadcrumb } from "@/components/seo/seo-breadcrumb";
import { sortLabels, sorts, type ShortDramaListResult } from "./data";
import { shortDramaListHref } from "./route";
import { H5ShortDramaCard, ShortDramaCard } from "./short-drama-card";
export function ShortDramaPage({ list }: { list: ShortDramaListResult }) {
const hrefMap = buildPageHrefMap(list.totalPages, (page) =>
shortDramaListHref(list.sort, page, list.themeSlug),
);
const resetHref = shortDramaListHref("hot", 1);
const themes = list.themes.filter((theme) => theme.name);
return (
<>
<SeoBreadcrumb items={[{ name: "首页", href: "/" }, { name: "短剧" }]} />
<main data-component="short-drama-page" className="flex w-full min-w-0 flex-col gap-[18px] overflow-x-clip px-4 py-3 lg:hidden">
<H5ChannelHeader title="短剧" />
<div
id="h5-list"
className="flex scroll-mt-16 flex-col gap-[9px] rounded-2xl border border-[#292138] bg-[#110D19] px-[19px] py-4"
>
{themes.length ? (
<div className="flex items-start gap-3">
<span className="shrink-0 text-xs leading-[18px] text-[#948F9E]">题材:</span>
<div className="flex min-w-0 flex-1 flex-wrap gap-x-3.5 gap-y-2">
<FilterOptionLink
label="全部"
href={shortDramaListHref(list.sort, 1)}
active={!list.themeSlug}
/>
{themes.map((theme) => (
<FilterOptionLink
key={theme.id}
label={theme.name || ""}
href={shortDramaListHref(list.sort, 1, theme.slug)}
active={Boolean(theme.slug && theme.slug === list.themeSlug)}
/>
))}
</div>
</div>
) : null}
<div className="flex items-start gap-3">
<span className="shrink-0 text-xs leading-[18px] text-[#948F9E]">排序:</span>
<div className="flex min-w-0 flex-1 flex-wrap gap-x-3.5 gap-y-2">
{sorts.map((item) => (
<FilterOptionLink
key={item}
label={sortLabels[item]}
href={shortDramaListHref(item, 1, list.themeSlug)}
active={item === list.sort}
/>
))}
<FilterOptionLink label="重置筛选" href={resetHref} />
</div>
</div>
</div>
<section className="flex flex-col gap-[18px]">
<H5SectionHeading title="全部短剧" more={false} />
{list.items.length ? (
<>
<div className="grid grid-cols-2 gap-x-[7px] gap-y-3">
{list.items.map((item) => (
<H5ShortDramaCard key={item.id} item={item} />
))}
</div>
{list.totalPages > 1 ? (
<Pagination page={list.page} total={list.totalPages} hrefMap={hrefMap} showJump={false} />
) : null}
</>
) : (
<EmptyState
title="暂无短剧"
description="当前筛选条件下没有可展示的短剧,换个题材或排序试试吧"
className="rounded-2xl px-4 py-12"
/>
)}
</section>
</main>
<main className="hidden lg:block">
<div className="design-frame flex flex-col gap-6 py-[43px]">
<ChannelHeader title="短剧" />
<div
id="pc-list"
className="flex scroll-mt-24 flex-col gap-4 rounded-[17px] border border-[#34304B] bg-[#151326] px-5 py-4"
>
{themes.length ? (
<div className="flex items-start gap-3">
<span className="shrink-0 pt-1.5 text-xs leading-[18px] text-white">题材:</span>
<div className="flex min-w-0 flex-1 flex-wrap gap-2">
<FilterChipLink label="全部" href={shortDramaListHref(list.sort, 1)} active={!list.themeSlug} />
{themes.map((theme) => (
<FilterChipLink
key={theme.id}
label={theme.name || ""}
href={shortDramaListHref(list.sort, 1, theme.slug)}
active={Boolean(theme.slug && theme.slug === list.themeSlug)}
/>
))}
</div>
</div>
) : null}
<div className="flex items-start gap-3">
<span className="shrink-0 pt-1.5 text-xs leading-[18px] text-white">排序:</span>
<div className="flex min-w-0 flex-1 flex-wrap gap-2">
{sorts.map((item) => (
<FilterChipLink
key={item}
label={sortLabels[item]}
href={shortDramaListHref(item, 1, list.themeSlug)}
active={item === list.sort}
/>
))}
<FilterChipLink label="重置筛选" href={resetHref} />
</div>
</div>
</div>
{list.items.length ? (
<div className="grid grid-cols-[repeat(6,266px)] justify-between gap-y-6">
{list.items.map((item) => (
<ShortDramaCard key={item.id} item={item} />
))}
</div>
) : (
<EmptyState
title="暂无短剧"
description="当前筛选条件下没有可展示的短剧,换个题材或排序试试吧"
className="rounded-3xl px-[110px] py-24"
/>
)}
</div>
{/* 分页放在 design-frame 外,避免 Chrome CSS zoom 热区错位导致点击无响应 */}
{list.items.length && list.totalPages > 1 ? (
<div className="flex justify-center px-6 py-6">
<Pagination page={list.page} total={list.totalPages} hrefMap={hrefMap} />
</div>
) : null}
<div className="design-frame flex flex-col gap-6 pb-[43px]">
<DownloadBanner />
</div>
</main>
<FloatingActions />
</>
);
}