整体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
+80 -314
View File
@@ -5,25 +5,24 @@ import { useRouter } from "next/navigation";
import { useEffect, useRef, useState, type ReactNode } from "react";
import { BackButton } from "@/components/common/back-button";
import { H5CommentSheet, type CommentTarget } from "@/components/common/comments";
import { pickPlayletCardTags } from "@/components/common/card-tags";
import { DecryptedImage } from "@/components/common/decrypted-image";
import {
dramaDetailHref,
getEpisodeState,
playHref,
totalEpisodeOf,
updateStatusLabel,
type DramaDetail,
type RelatedDrama,
} from "@/components/drama-detail/data";
import { MorePlayletsGrid } from "@/components/drama-detail/episodes";
import { openAppDownload } from "@/components/download/download-dialog";
import { EpisodeDirectory } from "@/components/media-page/episode-directory";
import { DramaRecommend, HlAction, TagLinks, tagLinkItems } from "@/components/media-page/parts";
import { playbackRates, XgPlayer, type XgPlayerInstance } from "@/components/player/xg-player";
import { CheckIcon, ChevronIcon } from "./icons";
import { useEpisodeRange } from "./play-episode-panel";
type Sheet = "episodes" | "speed" | "comments" | null;
type Sheet = "speed" | null;
/** 播完自动下一集倒计时(秒) */
const AUTO_NEXT_SECONDS = 3;
@@ -64,7 +63,6 @@ type H5PlayProps = {
onLike: () => void;
onCollect: () => void;
onShare: () => void;
commentTarget: CommentTarget | null;
onPlaySuccess?: () => void;
};
@@ -75,7 +73,7 @@ function LockedNotice() {
<button
type="button"
onClick={openAppDownload}
className="cursor-pointer inline-flex h-9 items-center justify-center rounded-full bg-[#F12B9E] px-6 text-sm font-medium text-white"
className="cursor-pointer inline-flex h-9 items-center justify-center rounded-md bg-[#FFB020] px-6 text-sm font-semibold text-[#1A1206]"
>
下载APP观看完整剧集
</button>
@@ -140,147 +138,6 @@ function SheetHead({ title, onClose, children }: { title: ReactNode; onClose: ()
);
}
function EpisodeSheet({
detail,
episode,
collected,
related = [],
onCollect,
onClose,
}: Pick<H5PlayProps, "detail" | "episode" | "collected" | "related" | "onCollect"> & {
onClose: () => void;
}) {
const { ranges, rangeIndex, setRangeIndex, episodes } = useEpisodeRange(detail, episode);
const [tab, setTab] = useState<"episodes" | "more">("episodes");
return (
<div className="flex max-h-[75vh] flex-col gap-3 px-4 pt-2.5 pb-[18px]">
<span className="mx-auto h-[5px] w-9 shrink-0 rounded-full bg-white/20" />
<div className="flex items-center gap-3">
<div className="flex min-w-0 flex-1 items-center gap-2.5">
<DecryptedImage
src={detail.cover}
alt=""
className="h-[75px] w-[54px] shrink-0 rounded-[3px] object-cover"
/>
<div className="flex min-w-0 flex-col gap-2">
<Link href={dramaDetailHref(detail)} className="flex items-center gap-2 text-sm leading-5 text-white">
<span className="truncate">{detail.title}</span>
<ChevronIcon direction="right" className="size-3 shrink-0" />
</Link>
<p className="text-xs leading-[18px] text-white/35">
{updateStatusLabel(detail.updateStatus)} 共{totalEpisodeOf(detail)}集
</p>
</div>
</div>
<button
type="button"
aria-pressed={collected}
onClick={onCollect}
className={`cursor-pointer shrink-0 rounded-full px-3 py-1 text-[10px] leading-4 ${collected ? "bg-white/5 text-[#F12B9E]" : "bg-[#F12B9E] text-white"}`}
>
{collected ? "已收藏" : "收藏"}
</button>
</div>
<div className="flex shrink-0 gap-6 overflow-x-auto text-sm leading-5 [scrollbar-width:none]">
{ranges.map((range, index) => (
<button
key={range.label}
type="button"
aria-pressed={tab === "episodes" && rangeIndex === index}
onClick={() => {
setTab("episodes");
setRangeIndex(index);
}}
className={`cursor-pointer shrink-0 ${tab === "episodes" && rangeIndex === index ? "text-white" : "text-white/35"}`}
>
{range.start}-{range.end}
</button>
))}
<button
type="button"
aria-pressed={tab === "more"}
onClick={() => setTab("more")}
className={`cursor-pointer shrink-0 ${tab === "more" ? "text-white" : "text-white/35"}`}
>
更多好剧
</button>
</div>
<div className="min-h-0 overflow-y-auto overscroll-contain">
{tab === "episodes" ? (
<div className="grid grid-cols-5 gap-x-[11px] gap-y-2">
{episodes.map((item) => {
const active = item === episode;
const locked = getEpisodeState(item, detail) === "locked";
if (active) {
return (
<Link
key={item}
href={playHref(detail.id, item, detail.slug)}
replace
onClick={onClose}
aria-current="true"
className="relative flex h-[58px] items-center justify-center overflow-hidden rounded-md bg-[rgba(241,43,158,0.1)] text-base leading-[22px] text-[#F12B9E] outline outline-1 -outline-offset-1 outline-[#F12B9E]"
>
{item}
<img src="/images/playing.svg" alt="" className="absolute top-0 right-0 size-5 p-[3px]" />
{!locked ? (
<span className="absolute top-0 left-0 flex h-[14px] w-[25px] items-center justify-center rounded-sm bg-[linear-gradient(136deg,#74FFED_0%,#10B9A2_100%)] text-[8px] leading-3 text-[#002D27]">
免费
</span>
) : null}
</Link>
);
}
if (!locked) {
return (
<Link
key={item}
href={playHref(detail.id, item, detail.slug)}
replace
onClick={onClose}
className="relative flex h-[58px] items-center justify-center overflow-hidden rounded-md bg-[#3A3D53] text-base leading-[22px] text-white"
>
{item}
<span className="absolute top-0 right-0 flex h-[14px] w-[25px] items-center justify-center rounded-sm bg-[linear-gradient(136deg,#74FFED_0%,#10B9A2_100%)] text-[8px] leading-3 text-[#002D27]">
免费
</span>
</Link>
);
}
return (
<Link
key={item}
href={playHref(detail.id, item, detail.slug)}
replace
onClick={onClose}
aria-label={`第${item}集(未解锁)`}
className="relative flex h-[58px] items-center justify-center gap-0.5 overflow-hidden rounded-md bg-white/10 text-base leading-[22px] text-[#828186] outline outline-1 -outline-offset-1 outline-white/5"
>
{item}
<svg viewBox="0 0 18 18" fill="none" className="size-3.5" aria-hidden="true">
<path
d="M5.29 7.65V5.25a3.71 3.71 0 0 1 7.42 0v2.4"
stroke="currentColor"
strokeWidth="1.35"
strokeLinecap="round"
/>
<rect x="3.75" y="7.5" width="10.5" height="8.25" rx="1.5" stroke="currentColor" strokeWidth="1.35" />
</svg>
</Link>
);
})}
</div>
) : (
<MorePlayletsGrid items={related} />
)}
</div>
</div>
);
}
export function H5Play({
detail,
episode,
@@ -294,14 +151,12 @@ export function H5Play({
onLike,
onCollect,
onShare,
commentTarget,
onPlaySuccess,
}: H5PlayProps) {
const router = useRouter();
const playerRef = useRef<XgPlayerInstance | null>(null);
const [rate, setRate] = useState(1);
const [sheet, setSheet] = useState<Sheet>(null);
const [cleared, setCleared] = useState(false);
const [introOpen, setIntroOpen] = useState(false);
/** null=未进入自动下一集;数字=剩余秒数 */
const [autoNextSeconds, setAutoNextSeconds] = useState<number | null>(null);
@@ -309,10 +164,14 @@ export function H5Play({
const [shouldAutoplay] = useState(consumeAutoplayFlag);
const closeSheet = () => setSheet(null);
const title = detail.title || "短剧";
const totalEpisode = totalEpisodeOf(detail);
const nextEpisode = episode + 1;
const hasNext = nextEpisode <= totalEpisode;
const nextHref = hasNext ? playHref(detail.id, nextEpisode, detail.slug) : null;
const prevHref = episode > 1 ? playHref(detail.id, episode - 1, detail.slug) : null;
const tags = tagLinkItems(pickPlayletCardTags(detail), "playlet");
const desc = detail.desc?.trim() || "";
useEffect(() => {
if (!sheet) return;
@@ -357,47 +216,11 @@ export function H5Play({
const likeCount = displayCountLike ?? (Number(detail.displayCountLike) || 0);
const collectCount = countCollect ?? (Number(detail.countCollect) || 0);
/** 已点赞 #F52C56 · 已收藏 #F68902 · 文案始终 #DCDCDC */
const sideItems = [
{
label: formatCount(likeCount),
icon: "/images/icon_like.svg",
active: liked,
activeColor: "#F52C56",
onClick: onLike,
},
{
label: "评论",
icon: "/images/comment.svg",
active: false,
activeColor: "#FFFFFF",
onClick: () => setSheet("comments"),
},
{
label: formatCount(collectCount),
icon: "/images/icon_collect.svg",
active: collected,
activeColor: "#F68902",
onClick: onCollect,
},
{
label: "分享",
icon: "/images/share_h5.svg",
active: false,
activeColor: "#FFFFFF",
onClick: onShare,
},
];
return (
<div data-component="drama-h5-play" className="fixed inset-0 z-30 flex flex-col bg-[#0E0E0E] lg:hidden">
<div className="relative min-h-0 flex-1 overflow-hidden">
<div data-component="hl-drama-play-h5" className="flex flex-col bg-[#0C0B10] lg:hidden">
<div className="sticky top-0 z-30 aspect-[3/4] max-h-[72vh] w-full overflow-hidden bg-black">
{locked ? (
<DecryptedImage
src={detail.cover}
alt={detail.title}
className="absolute inset-0 size-full object-cover"
/>
<DecryptedImage src={detail.cover} alt={`${title} 第${episode}集`} className="absolute inset-0 size-full object-cover" />
) : (
<XgPlayer
src={src}
@@ -410,146 +233,93 @@ export function H5Play({
}}
onPlaySuccess={onPlaySuccess}
onEnded={handleEnded}
analyticsKind="drama"
clickToPlay={!shouldAutoplay}
className="absolute inset-0"
options={{ ignores: ["playbackrate", "cssfullscreen"] }}
/>
)}
<div className="pointer-events-none absolute inset-x-0 top-0 h-[min(300px,40%)] bg-[linear-gradient(180deg,#000_0%,rgba(0,0,0,0)_100%)]" />
{!cleared ? (
<div className="pointer-events-none absolute inset-x-0 bottom-0 h-[min(212px,30%)] bg-[linear-gradient(180deg,rgba(0,0,0,0)_0%,rgba(0,0,0,0.75)_100%)]" />
) : null}
<div className="absolute inset-x-0 top-0 z-20 flex items-center gap-1 px-4 pt-[calc(12px+env(safe-area-inset-top))] pb-3">
<div className="pointer-events-none absolute inset-x-0 top-0 h-20 bg-[linear-gradient(180deg,rgba(0,0,0,0.7)_0%,rgba(0,0,0,0)_100%)]" />
<div className="absolute inset-x-0 top-0 z-20 flex items-center gap-2 px-3 pt-[calc(8px+env(safe-area-inset-top))] pb-2">
<BackButton fallback={dramaDetailHref(detail)} />
<p className="min-w-0 flex-1 truncate text-lg leading-6 font-medium text-white">第{episode}集</p>
<div className="flex items-center gap-3">
<button
type="button"
onClick={() => setSheet("speed")}
className="cursor-pointer flex items-center gap-1 text-xs leading-[18px] font-medium text-white"
>
<img src="/images/speed.svg" alt="" className="size-[18px]" />
{rate === 1 ? "1.0" : rate}x
</button>
<Link href="/feedback" aria-label="意见反馈" className="size-6 shrink-0">
<img src="/images/feedback.svg" alt="" className="size-full" />
</Link>
</div>
<p className="min-w-0 flex-1 truncate text-sm leading-5 text-white/90">
第 {episode} / {totalEpisode} 集
</p>
<button
type="button"
onClick={() => setSheet("speed")}
className="cursor-pointer flex items-center gap-1 rounded bg-black/40 px-2 py-1 text-xs leading-[18px] font-medium text-white"
>
<img src="/images/speed.svg" alt="" className="size-4" />
{rate === 1 ? "1.0" : rate}x
</button>
</div>
{locked ? <LockedNotice /> : null}
{!cleared ? (
<>
<div className="pointer-events-none absolute right-4 bottom-[120px] z-10 inline-flex flex-col items-center gap-[18px]">
<div className="flex flex-col items-center gap-2.5">
{sideItems.map((item) => (
<button
key={item.icon}
type="button"
aria-pressed={item.active}
onClick={item.onClick}
className="pointer-events-auto cursor-pointer flex flex-col items-center text-center text-xs leading-[18px] font-medium text-[#DCDCDC]"
>
<span className="relative size-[30px] overflow-hidden">
<span
aria-hidden="true"
className="absolute inset-0"
style={{
background: item.active ? item.activeColor : "#FFFFFF",
mask: `url(${item.icon}) center / 24px no-repeat`,
WebkitMask: `url(${item.icon}) center / 24px no-repeat`,
}}
/>
</span>
{item.label}
</button>
))}
</div>
</div>
<div className="pointer-events-none absolute bottom-[68px] left-4 z-10 flex w-[min(278px,calc(100%-90px))] flex-col gap-2.5">
<button
type="button"
aria-label="选集"
onClick={() => setSheet("episodes")}
className="pointer-events-auto flex max-w-full cursor-pointer items-center gap-[5px] text-left text-xs leading-[18px] font-medium text-white"
>
<h1 className="min-w-0 truncate">{detail.title}</h1>
<ChevronIcon direction="right" className="size-[18px] shrink-0" />
</button>
<div className="flex items-end gap-1.5">
<p
className={`max-w-[248px] text-xs leading-[18px] text-white/65 ${introOpen ? "pointer-events-auto max-h-40 overflow-y-auto" : "line-clamp-2"}`}
>
{detail.desc}
</p>
<button
type="button"
onClick={() => setIntroOpen((open) => !open)}
className="pointer-events-auto cursor-pointer shrink-0 text-xs leading-[18px] text-white"
>
{introOpen ? "收起" : "展开"}
</button>
</div>
</div>
</>
) : null}
{autoNextSeconds != null && hasNext ? (
<button
type="button"
onClick={goNextEpisode}
className="absolute inset-x-4 bottom-3 z-20 flex cursor-pointer items-center justify-between rounded-md bg-white/10 px-3 py-1.5 text-sm leading-5"
className="absolute inset-x-3 bottom-3 z-20 flex cursor-pointer items-center justify-between rounded-md bg-black/60 px-3 py-2 text-sm leading-5"
>
<span className="text-white">自动播放下一集</span>
<span className="text-[#FFAB6B]">倒计时{autoNextSeconds}s</span>
<span className="text-white">即将播放第 {nextEpisode} 集</span>
<span className="text-[#FFB020]">{autoNextSeconds}s</span>
</button>
) : null}
</div>
<div className="flex min-h-[58px] shrink-0 items-center gap-2.5 bg-[#1A1A1A] px-4 pt-1.5 pb-[calc(6px+env(safe-area-inset-bottom))]">
<button
type="button"
onClick={() => setSheet("episodes")}
className="cursor-pointer flex min-w-0 flex-1 items-center justify-between rounded-[3px] bg-white/5 px-3 py-1.5 text-xs leading-[18px] text-white"
>
<span className="truncate">选集·全{totalEpisode}集·免费观看</span>
<ChevronIcon direction="up" className="size-6 shrink-0" />
</button>
{cleared ? (
<button
type="button"
aria-label="评论"
onClick={() => setSheet("comments")}
className="cursor-pointer rounded-[3px] bg-white/5 px-3 py-1.5 text-white"
>
<img src="/images/comment.svg" alt="" className="size-6" />
</button>
) : null}
<button
type="button"
aria-label={cleared ? "退出清屏" : "清屏"}
aria-pressed={cleared}
onClick={() => setCleared((value) => !value)}
className="cursor-pointer text-white"
>
<img src={cleared ? "/images/unscreen.svg" : "/images/screen.svg"} alt="" className="size-6" />
</button>
</div>
<div className="flex flex-col gap-6 px-4 pt-4 pb-10">
<article className="flex flex-col gap-3">
<p className="text-[11px] leading-4 tracking-[0.15em] text-[#FFB020]">
短剧 · {updateStatusLabel(detail.updateStatus)} · 共{totalEpisode}集
</p>
<h1 className="text-lg leading-7 font-bold text-white">
{title}
<span className="ml-2 text-[#FFB020]">第{episode}集</span>
</h1>
<TagLinks tags={tags} compact />
{desc ? (
<div className="flex items-end gap-1.5">
<p className={`min-w-0 flex-1 text-[13px] leading-[22px] text-[#A9A7B3] ${introOpen ? "" : "line-clamp-2"}`}>{desc}</p>
<button
type="button"
onClick={() => setIntroOpen((open) => !open)}
className="cursor-pointer shrink-0 text-xs leading-[22px] text-[#FFB020]"
>
{introOpen ? "收起" : "展开"}
</button>
</div>
) : null}
<div className="flex items-center gap-2">
<HlAction kind="like" label={formatCount(likeCount)} active={liked} onClick={onLike} compact />
<HlAction kind="collect" label={formatCount(collectCount)} active={collected} onClick={onCollect} compact />
<HlAction kind="share" label="分享" onClick={onShare} compact />
</div>
<nav aria-label="分集导航" className="grid grid-cols-2 gap-2 text-xs leading-[18px]">
{prevHref ? (
<Link href={prevHref} className="flex items-center gap-1 rounded-md border border-white/12 px-3 py-2 text-[#D8D6DF]">
<ChevronIcon direction="left" className="size-3.5" />
上一集 · 第{episode - 1}集
</Link>
) : (
<span />
)}
{nextHref ? (
<Link
href={nextHref}
className="flex items-center justify-end gap-1 rounded-md border border-white/12 px-3 py-2 text-[#D8D6DF]"
>
下一集 · 第{nextEpisode}集
<ChevronIcon direction="right" className="size-3.5" />
</Link>
) : null}
</nav>
</article>
<BottomSheet open={sheet === "episodes"} onClose={closeSheet} label="选集">
<EpisodeSheet
detail={detail}
episode={episode}
collected={collected}
related={related}
onCollect={onCollect}
onClose={closeSheet}
/>
</BottomSheet>
<EpisodeDirectory detail={detail} current={episode} variant="h5" />
<DramaRecommend items={related} compact />
</div>
<BottomSheet open={sheet === "speed"} onClose={closeSheet} label="倍速" className="gap-3 px-4 py-[18px]">
<SheetHead title="倍速" onClose={closeSheet} />
@@ -565,17 +335,13 @@ export function H5Play({
setRate(item);
closeSheet();
}}
className={`cursor-pointer flex h-12 items-center justify-between text-base leading-[22px] ${item === rate ? "text-[#F12B9E]" : "text-white"}`}
className={`cursor-pointer flex h-12 items-center justify-between text-base leading-[22px] ${item === rate ? "text-[#FFB020]" : "text-white"}`}
>
{item}x{item === rate ? <CheckIcon /> : null}
</button>
))}
</div>
</BottomSheet>
<BottomSheet open={sheet === "comments"} onClose={closeSheet} label="评论">
<H5CommentSheet onClose={closeSheet} target={commentTarget} />
</BottomSheet>
</div>
);
}