整体UI调整

This commit is contained in:
谢宇宁
2026-10-26 19:51:59 +07:00
parent c8895f407c
commit eeb9986923
112 changed files with 1507 additions and 4255 deletions
+79 -114
View File
@@ -3,20 +3,13 @@ import Link from "next/link";
import { CardTags } from "@/components/common/card-tags";
import { DecryptedImage } from "@/components/common/decrypted-image";
import {
MEDIA_CARD_COVER,
MEDIA_CARD_DESC,
MEDIA_CARD_DESC_SM,
MEDIA_CARD_EPISODES,
MEDIA_CARD_EPISODES_H5,
MEDIA_CARD_FOOTER_H5,
MEDIA_CARD_INFO_H5,
MEDIA_CARD_META,
MEDIA_CARD_ROOT,
MEDIA_CARD_TITLE_H5,
MEDIA_CARD_TITLE_PC,
} from "@/components/common/media-card-hover";
import { RankNumber } from "@/components/common/rank-number";
import { Badge } from "@/components/home/section-heading";
EyeIcon,
formatDay,
HL_COVER,
HL_COVER_IMG,
HL_TITLE_LINK,
HlBadge,
} from "@/components/common/media-meta";
import type { ShortDramaItem } from "@/components/short-drama/data";
import { IMG_PLACEHOLDER } from "@/lib/image/decrypt";
@@ -24,59 +17,68 @@ export function videoHref(id: string, slug?: string | null) {
return `/video/${(slug?.trim() || id).trim()}`;
}
export function VideoCard({ item, rank }: { item: ShortDramaItem; rank?: number }) {
if (item.kind === "ad") {
return (
<a
href={item.href || "#download"}
target={item.href ? "_blank" : undefined}
rel={item.href ? "sponsored nofollow noopener noreferrer" : undefined}
className={`block w-[324px] ${MEDIA_CARD_ROOT}`}
>
<div className="relative h-[192px] overflow-hidden rounded-t-lg">
<DecryptedImage src={item.cover} fallback={IMG_PLACEHOLDER} alt="" className={MEDIA_CARD_COVER} />
<img src="/logo.svg" alt="海角社区" className="absolute top-[25px] left-[15px] h-[27px] w-[120px]" />
</div>
<div className="flex min-h-24 flex-col justify-center gap-1.5 px-2.5 py-3">
<h3 className={MEDIA_CARD_TITLE_PC}>{item.title}</h3>
<p className={`${MEDIA_CARD_DESC} text-white/60`}>{item.subtitle}</p>
</div>
</a>
);
}
/** 排行序号:No.01(琥珀色,放在标题前) */
function RankLabel({ rank, className = "" }: { rank?: number; className?: string }) {
if (rank === undefined) return null;
return (
<span className={`mr-1.5 font-bold text-[#FFB020] tabular-nums ${className}`}>No.{String(rank).padStart(2, "0")}</span>
);
}
const detailHref = item.href || videoHref(item.id, item.slug);
/** 视频卡元信息:观看数 + 发布日期 */
function VideoMeta({ item, className }: { item: Extract<ShortDramaItem, { kind: "drama" }>; className: string }) {
const day = formatDay(item.date);
return (
<p className={`flex min-w-0 items-center gap-2 text-[#8E8C99] ${className}`}>
{item.heat ? (
<span className="inline-flex shrink-0 items-center gap-1">
<EyeIcon />
{item.heat}
</span>
) : null}
{item.heat && day ? <span aria-hidden="true" className="h-2.5 w-px bg-white/15" /> : null}
{day ? <time dateTime={day}>{day}</time> : null}
</p>
);
}
function AdVideoCard({ item, compact }: { item: ShortDramaItem; compact?: boolean }) {
return (
<a
href={item.href || (compact ? "#h5-download" : "#download")}
target={item.href ? "_blank" : undefined}
rel={item.href ? "sponsored nofollow noopener noreferrer" : undefined}
className={`group flex flex-col ${compact ? "gap-1.5" : "w-[324px] gap-2.5"}`}
>
<span className={`${HL_COVER} aspect-[16/10]`}>
<DecryptedImage src={item.cover} fallback={IMG_PLACEHOLDER} alt={item.title} className={HL_COVER_IMG} />
<span className="absolute top-0 left-0 rounded-br-md bg-white/85 px-1.5 py-0.5 text-[10px] leading-[14px] text-black">
推广
</span>
</span>
<span className={`line-clamp-2 text-white ${compact ? "text-sm leading-5" : "media-card-title-md"}`}>{item.title}</span>
</a>
);
}
export function VideoCard({ item, rank }: { item: ShortDramaItem; rank?: number }) {
if (item.kind === "ad") return <AdVideoCard item={item} />;
const href = item.href || videoHref(item.id, item.slug);
return (
<article data-component="video-card" className={`w-[324px] ${MEDIA_CARD_ROOT}`}>
<Link href={detailHref} className="block">
<div className="relative h-[192px] overflow-hidden rounded-t-lg">
<DecryptedImage src={item.cover} fallback={IMG_PLACEHOLDER} alt="" className={MEDIA_CARD_COVER} />
{item.badge ? (
<div className="absolute top-[15.5px] right-4">
<Badge tone={item.badge} />
</div>
) : null}
{item.episodes ? (
<span
className={`absolute right-2 bottom-2 rounded-md bg-black/60 px-3 py-2 text-white ${MEDIA_CARD_EPISODES}`}
>
{item.episodes}
</span>
) : null}
</div>
<div className="flex min-w-0 flex-col gap-1.5 px-2.5 pt-3">
<h3 className={`flex min-h-7 items-center gap-1.5 ${MEDIA_CARD_TITLE_PC}`}>
<RankNumber rank={rank} className="media-card-title" />
<span className="min-w-0 truncate">{item.title}</span>
</h3>
<p className={`${MEDIA_CARD_DESC} text-white/60`}>{item.subtitle}</p>
</div>
<article data-component="hl-video-card" className="group flex w-[324px] flex-col gap-2.5">
<Link href={href} tabIndex={-1} aria-hidden="true" className={`${HL_COVER} aspect-[16/10]`}>
<DecryptedImage src={item.cover} fallback={IMG_PLACEHOLDER} alt={item.title} className={HL_COVER_IMG} />
<HlBadge tone={item.badge} />
</Link>
<div className={`flex min-w-0 items-center justify-between gap-2 px-2.5 pt-1.5 pb-3 ${MEDIA_CARD_META}`}>
<CardTags tags={item.tags} kind="video" className="min-w-0 text-white/60" />
<span className="shrink-0 text-[#F92882]">{item.heat}</span>
</div>
<h3 className="media-card-title-md line-clamp-2 min-h-[2.5em] font-medium text-[#F4F3F7]">
<RankLabel rank={rank} />
<Link href={href} title={item.title} className={HL_TITLE_LINK}>
{item.title}
</Link>
</h3>
<VideoMeta item={item} className="media-card-desc" />
<CardTags tags={item.tags} kind="video" className="media-card-meta min-w-0 text-[#B49A6A]" />
</article>
);
}
@@ -84,65 +86,28 @@ export function VideoCard({ item, rank }: { item: ShortDramaItem; rank?: number
export function H5VideoCard({
item,
rank,
showEpisodes = true,
}: {
item: ShortDramaItem;
rank?: number;
/** @deprecated 新卡片不在封面显示集数,保留参数兼容调用方 */
showEpisodes?: boolean;
}) {
if (item.kind === "ad") {
return (
<a
href={item.href || "#h5-download"}
target={item.href ? "_blank" : undefined}
rel={item.href ? "sponsored nofollow noopener noreferrer" : undefined}
className={`block ${MEDIA_CARD_ROOT}`}
>
<div className="relative aspect-[7/4] overflow-hidden rounded-t-lg">
<DecryptedImage src={item.cover} fallback={IMG_PLACEHOLDER} alt="" className={MEDIA_CARD_COVER} />
<div className="absolute inset-0 bg-black/40" />
<img src="/logo.svg" alt="海角社区" className="absolute top-[17px] left-[13px] h-4 w-[71px]" />
</div>
<div className={`${MEDIA_CARD_INFO_H5} pb-1.5`}>
<h3 className={MEDIA_CARD_TITLE_H5}>{item.title}</h3>
<p className={`${MEDIA_CARD_DESC_SM} text-[#8C859C]`}>{item.subtitle}</p>
</div>
</a>
);
}
const detailHref = item.href || videoHref(item.id, item.slug);
if (item.kind === "ad") return <AdVideoCard item={item} compact />;
const href = item.href || videoHref(item.id, item.slug);
return (
<article data-component="h5-video-card" className={MEDIA_CARD_ROOT}>
<Link href={detailHref} className="block">
<div className="relative aspect-[7/4] overflow-hidden rounded-t-lg">
<DecryptedImage src={item.cover} fallback={IMG_PLACEHOLDER} alt="" className={MEDIA_CARD_COVER} />
{item.badge ? (
<div className="absolute top-2 right-2">
<Badge tone={item.badge} className="h-6" />
</div>
) : null}
{showEpisodes && item.episodes ? (
<span
className={`absolute right-2 bottom-[3px] flex h-6 items-center rounded-lg bg-[#08060D]/88 px-1.5 text-white ${MEDIA_CARD_EPISODES_H5}`}
>
{item.episodes}
</span>
) : null}
</div>
<div className={MEDIA_CARD_INFO_H5}>
<h3 className={`flex items-center gap-1 ${MEDIA_CARD_TITLE_H5}`}>
<RankNumber rank={rank} className="text-sm leading-5" />
<span className="truncate">{item.title}</span>
</h3>
<p className={`${MEDIA_CARD_DESC_SM} text-[#8C859C]`}>{item.subtitle}</p>
</div>
<article data-component="hl-video-card-h5" className="group flex min-w-0 flex-col gap-1.5">
<Link href={href} tabIndex={-1} aria-hidden="true" className={`${HL_COVER} aspect-[16/10]`}>
<DecryptedImage src={item.cover} fallback={IMG_PLACEHOLDER} alt={item.title} className={HL_COVER_IMG} />
<HlBadge tone={item.badge} small />
</Link>
<div className={MEDIA_CARD_FOOTER_H5}>
<CardTags tags={item.tags} kind="video" className="min-w-0 text-[#A89EB5]" />
<span className="shrink-0 text-[#F12B9E]">{item.heat}</span>
</div>
<h3 className="line-clamp-2 min-h-10 text-sm leading-5 font-medium text-[#F4F3F7]">
<RankLabel rank={rank} className="text-xs" />
<Link href={href} title={item.title} className={HL_TITLE_LINK}>
{item.title}
</Link>
</h3>
<VideoMeta item={item} className="text-[11px] leading-4" />
</article>
);
}