整体UI调整
This commit is contained in:
@@ -37,6 +37,8 @@ export type ShortDramaItem =
|
||||
episodes: string;
|
||||
badge?: BadgeTone;
|
||||
cover: string;
|
||||
/** 发布时间(接口原值,视频卡展示日期用) */
|
||||
date?: string;
|
||||
/** 覆盖默认详情/播放链接(如历史继续看到某集) */
|
||||
href?: string;
|
||||
}
|
||||
|
||||
@@ -2,79 +2,75 @@ 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 { CoverRankBadge, RankNumber } from "@/components/common/rank-number";
|
||||
import { Badge } from "@/components/home/section-heading";
|
||||
import { EyeIcon, HL_COVER, HL_COVER_IMG, HL_TITLE_LINK, HlBadge } from "@/components/common/media-meta";
|
||||
import { IMG_PLACEHOLDER } from "@/lib/image/decrypt";
|
||||
|
||||
import { dramaHref, type ShortDramaItem } from "./data";
|
||||
|
||||
export function ShortDramaCard({ 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-[266px] ${MEDIA_CARD_ROOT}`}
|
||||
>
|
||||
<div className="relative h-[355px] 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-[21px] left-[21px] h-[19px] w-[84px]" />
|
||||
</div>
|
||||
<div className="flex min-h-[96px] flex-col justify-center gap-1 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 || dramaHref(item.id, item.slug);
|
||||
/** 短剧卡元信息:集数 + 热度(文字行,不叠在封面上) */
|
||||
function DramaMeta({ item, className }: { item: Extract<ShortDramaItem, { kind: "drama" }>; className: string }) {
|
||||
return (
|
||||
<p className={`flex min-w-0 items-center gap-2 text-[#8E8C99] ${className}`}>
|
||||
{item.episodes ? <span className="shrink-0 text-[#D9C59A]">共{item.episodes}</span> : null}
|
||||
{item.episodes && item.heat ? <span aria-hidden="true" className="h-2.5 w-px bg-white/15" /> : null}
|
||||
{item.heat ? (
|
||||
<span className="inline-flex min-w-0 items-center gap-1 truncate">
|
||||
<EyeIcon className="size-3.5 shrink-0" />
|
||||
{item.heat}
|
||||
</span>
|
||||
) : null}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
||||
function AdDramaCard({ 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-[266px] gap-2.5"}`}
|
||||
>
|
||||
<span className={`${HL_COVER} aspect-[2/3]`}>
|
||||
<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={`truncate text-white ${compact ? "text-sm leading-5" : "media-card-title-md"}`}>{item.title}</span>
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
export function ShortDramaCard({ item, rank }: { item: ShortDramaItem; rank?: number }) {
|
||||
if (item.kind === "ad") return <AdDramaCard item={item} />;
|
||||
const href = item.href || dramaHref(item.id, item.slug);
|
||||
|
||||
return (
|
||||
<article data-component="short-drama-card" className={`w-[266px] ${MEDIA_CARD_ROOT}`}>
|
||||
<Link href={detailHref} className="block">
|
||||
<div className="relative h-[355px] 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} />
|
||||
</div>
|
||||
) : null}
|
||||
{item.episodes ? (
|
||||
<span
|
||||
className={`absolute right-2 bottom-2 rounded-md bg-black/60 px-2.5 py-1.5 font-medium text-white ${MEDIA_CARD_EPISODES}`}
|
||||
>
|
||||
{item.episodes}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="flex min-w-0 flex-col gap-1 px-2.5 pt-3">
|
||||
<h3 className={`flex min-h-7 items-center gap-1 ${MEDIA_CARD_TITLE_PC}`}>
|
||||
<RankNumber rank={rank} />
|
||||
<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-drama-card" className="group flex w-[266px] flex-col gap-2">
|
||||
<Link href={href} tabIndex={-1} aria-hidden="true" className={`${HL_COVER} aspect-[2/3]`}>
|
||||
<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 pb-3 ${MEDIA_CARD_META}`}>
|
||||
<CardTags tags={item.tags} kind="playlet" className="min-w-0 text-white/60" />
|
||||
<span className="shrink-0 text-[#F92882]">{item.heat}</span>
|
||||
</div>
|
||||
<h3 className="media-card-title-md truncate font-medium text-[#F4F3F7]">
|
||||
<RankLabel rank={rank} />
|
||||
<Link href={href} title={item.title} className={HL_TITLE_LINK}>
|
||||
{item.title}
|
||||
</Link>
|
||||
</h3>
|
||||
<DramaMeta item={item} className="media-card-desc" />
|
||||
{item.subtitle ? (
|
||||
<p className="media-card-desc line-clamp-2 min-h-[2.4em] text-[#7D7A88]">{item.subtitle}</p>
|
||||
) : null}
|
||||
<CardTags tags={item.tags} kind="playlet" className="media-card-meta min-w-0 text-[#B49A6A]" />
|
||||
</article>
|
||||
);
|
||||
}
|
||||
@@ -82,63 +78,29 @@ export function ShortDramaCard({ item, rank }: { item: ShortDramaItem; rank?: nu
|
||||
export function H5ShortDramaCard({
|
||||
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-[3/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 || dramaHref(item.id, item.slug);
|
||||
if (item.kind === "ad") return <AdDramaCard item={item} compact />;
|
||||
const href = item.href || dramaHref(item.id, item.slug);
|
||||
|
||||
return (
|
||||
<article data-component="h5-short-drama-card" className={MEDIA_CARD_ROOT}>
|
||||
<Link href={detailHref} className="block">
|
||||
<div className="relative aspect-[3/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}
|
||||
<CoverRankBadge rank={rank} />
|
||||
{showEpisodes ? (
|
||||
<span
|
||||
className={`absolute right-2 bottom-2 rounded-lg bg-[#08060D]/88 px-1.5 py-0.5 text-white ${MEDIA_CARD_EPISODES_H5}`}
|
||||
>
|
||||
{item.episodes}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<div className={MEDIA_CARD_INFO_H5}>
|
||||
<h3 className={MEDIA_CARD_TITLE_H5}>{item.title}</h3>
|
||||
<p className={`${MEDIA_CARD_DESC_SM} text-[#8C859C]`}>{item.subtitle}</p>
|
||||
</div>
|
||||
<article data-component="hl-drama-card-h5" className="group flex min-w-0 flex-col gap-1">
|
||||
<Link href={href} tabIndex={-1} aria-hidden="true" className={`${HL_COVER} aspect-[2/3]`}>
|
||||
<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="playlet" className="min-w-0 text-[#A89EB5]" />
|
||||
<span className="shrink-0 text-[#F12B9E]">{item.heat}</span>
|
||||
</div>
|
||||
<h3 className="mt-0.5 truncate 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>
|
||||
<DramaMeta item={item} className="text-[11px] leading-4" />
|
||||
{item.subtitle ? <p className="line-clamp-2 text-[11px] leading-4 text-[#7D7A88]">{item.subtitle}</p> : null}
|
||||
</article>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user