整体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
+1
View File
@@ -34,6 +34,7 @@ function mapHotVideoItem(item: VideoData): ShortDramaItem {
heat: formatHeat(item.watchNum),
episodes: "",
cover: (item.coverImg || "").trim(),
date: item.addedTime || undefined,
};
}
+58 -181
View File
@@ -1,19 +1,14 @@
"use client";
import Link from "next/link";
import { useState, type ReactNode } from "react";
import type { ReactNode } from "react";
import { BackButton } from "@/components/common/back-button";
import { AdBanners, AdIcons } from "@/components/common/ads";
import { H5CommentsTab, useComments, type CommentTarget } from "@/components/common/comments";
import { BackButton } from "@/components/common/back-button";
import { HlAction, InfoList, SectionTitle, TagLinks, VideoRecommend, type InfoRow, type TagLinkItem } from "@/components/media-page/parts";
import { XgPlayer } from "@/components/player/xg-player";
import type { ShortDramaItem } from "@/components/short-drama/data";
import { tagPageHref } from "@/components/tag/href";
import { H5VideoCard } from "@/components/video/video-card";
import { formatCount, formatWatchNum, type VideoDetail } from "./data";
type Tab = "intro" | "comments";
import { formatCount, type VideoDetail } from "./data";
type StatsProps = {
liked: boolean;
@@ -27,35 +22,16 @@ type StatsProps = {
onShare: () => void;
};
function H5VideoPlayer({
/** H5 视频页:播放器吸顶 → 正文(h1 / 资料 / 标签 / 介绍 / 操作)→ 相关视频推荐(替代原评论标签页) */
export function H5VideoPlay({
detail,
src,
related = [],
infoRows,
tags,
onPlaySuccess,
}: {
detail: VideoDetail;
src: string;
onPlaySuccess?: () => void;
}) {
// 上下文由 VideoPlayPage 统一设置;此处仅绑定播放器行为
return (
<div className="sticky top-0 z-20 aspect-video w-full overflow-hidden bg-black">
<XgPlayer
src={src}
poster={detail.coverImg || ""}
onPlaySuccess={onPlaySuccess}
analyticsKind="video"
clickToPlay
className="absolute inset-0"
options={{ ignores: ["cssfullscreen"], fullscreen: { rotateFullscreen: true } }}
/>
<BackButton fallback="/video/hot" className="absolute top-3 left-4 z-10" />
</div>
);
}
function IntroTab({
detail,
related,
adGrid,
bannerAds,
liked,
likeNum,
collected,
@@ -63,163 +39,64 @@ function IntroTab({
onLike,
onCollect,
onShare,
adGrid,
bannerAds,
}: StatsProps & {
detail: VideoDetail;
related: ShortDramaItem[];
adGrid?: ReactNode;
bannerAds?: ReactNode;
}) {
const tags = (detail.tags ?? []).filter((tag) =>
Boolean(tag.name?.trim() || tag.slug?.trim() || tag.id),
);
const likeCount = likeNum ?? detail.likeNum;
const collectCount = countCollect ?? detail.countCollect;
return (
<div className="flex flex-col gap-[18px] bg-[#010406] px-4 py-3">
<h1 className="line-clamp-2 text-sm leading-5 font-medium text-white/80">{detail.title}</h1>
{detail.desc?.trim() ? (
<p className="text-xs leading-[18px] text-white/80">{detail.desc}</p>
) : null}
{tags.length ? (
<div className="flex flex-wrap items-center gap-1.5">
{tags.map((tag) => {
const name = (tag.tagName || tag.name || "").trim() || tag.slug?.trim() || "";
if (!name) return null;
const canLink = Boolean(tag.slug?.trim() || tag.id != null);
return canLink ? (
<Link
key={tag.slug || tag.id || name}
href={tagPageHref({ slug: tag.slug, id: tag.id }, "video")}
className="rounded-[3px] bg-white/10 px-1.5 py-0.5 text-xs leading-[18px] text-white/90 hover:text-[#F12B9E]"
>
#{name}
</Link>
) : (
<span
key={name}
className="rounded-[3px] bg-white/10 px-1.5 py-0.5 text-xs leading-[18px] text-white/90"
>
#{name}
</span>
);
})}
</div>
) : null}
<div className="flex items-center justify-between text-xs leading-[18px]">
<span className="text-[#BDBDBD]">{formatWatchNum(detail.watchNum)}</span>
<div className="flex items-center gap-3 text-[#BDBDBD]">
<button type="button" aria-pressed={liked} onClick={onLike} className="cursor-pointer flex items-center gap-0.5">
<svg viewBox="0 0 16 16" className="size-4" aria-hidden="true">
<path
d="M8 14c-.2 0-.4-.07-.56-.2C5.3 12 2 9.7 2 6.6 2 4.6 3.4 3 5.2 3c1.1 0 2.1.6 2.8 1.5C8.7 3.6 9.7 3 10.8 3 12.6 3 14 4.6 14 6.6c0 3.1-3.3 5.4-5.44 7.2-.16.13-.36.2-.56.2Z"
fill={liked ? "#F52C56" : "none"}
stroke="#F52C56"
strokeWidth="1.4"
/>
</svg>
{formatCount(likeCount)}
</button>
<button
type="button"
aria-pressed={collected}
onClick={onCollect}
className="cursor-pointer flex items-center gap-0.5"
>
<svg viewBox="0 0 16 16" className="size-4" aria-hidden="true">
<path
d="m8 2 1.8 3.7 4 .6-2.9 2.8.7 4L8 11.2l-3.6 1.9.7-4-2.9-2.8 4-.6L8 2Z"
fill={collected ? "#FFC53D" : "none"}
stroke="#FFC53D"
strokeWidth="1.4"
strokeLinejoin="round"
/>
</svg>
{formatCount(collectCount)}
</button>
<button type="button" onClick={onShare} className="cursor-pointer flex items-center gap-0.5">
<img src="/images/share_h5.svg" alt="" className="size-4" />
分享
</button>
</div>
</div>
{/* icon 广告 → 热门推荐 → banner 广告 */}
{adGrid ?? <AdIcons variant="h5" />}
{related.length ? (
<section className="flex flex-col items-center gap-3">
<h2 className="w-full text-lg leading-6 font-semibold text-white">热门推荐</h2>
<div className="grid w-full grid-cols-2 gap-x-[7px] gap-y-3">
{related.map((item) => (
<H5VideoCard key={item.id} item={item} showEpisodes={false} />
))}
</div>
</section>
) : null}
{bannerAds ?? <AdBanners variant="h5" />}
</div>
);
}
export function H5VideoPlay({
detail,
src,
related = [],
commentTarget,
onPlaySuccess,
adGrid,
bannerAds,
...stats
}: StatsProps & {
detail: VideoDetail;
src: string;
related?: ShortDramaItem[];
commentTarget: CommentTarget | null;
infoRows: InfoRow[];
tags: TagLinkItem[];
onPlaySuccess?: () => void;
adGrid?: ReactNode;
bannerAds?: ReactNode;
}) {
const [tab, setTab] = useState<Tab>("intro");
const comments = useComments({ target: commentTarget, initialSort: "最新" });
const tabs: { key: Tab; label: string }[] = [
{ key: "intro", label: "简介" },
{ key: "comments", label: `评论(${comments.total})` },
];
const title = detail.title || "视频";
const desc = detail.desc?.trim() || "";
return (
<div data-component="video-h5-play" className="flex flex-col bg-[#010406] lg:hidden">
<H5VideoPlayer detail={detail} src={src} onPlaySuccess={onPlaySuccess} />
<div role="tablist" className="flex gap-3 px-4 pt-[18px]">
{tabs.map((item) => (
<button
key={item.key}
type="button"
role="tab"
aria-selected={tab === item.key}
onClick={() => setTab(item.key)}
className={`cursor-pointer text-base leading-[22px] ${tab === item.key ? "font-medium text-white" : "text-[#8D8E8F]"}`}
>
{item.label}
</button>
))}
</div>
{tab === "intro" ? (
<IntroTab detail={detail} related={related} adGrid={adGrid} bannerAds={bannerAds} {...stats} />
) : (
<H5CommentsTab
state={comments}
footerExtra={
bannerAds ? <div className="px-4 py-3">{bannerAds}</div> : <AdBanners variant="h5" className="px-4 py-3" />
}
<div data-component="hl-video-play-h5" className="flex flex-col bg-[#0C0B10] lg:hidden">
<div className="sticky top-0 z-20 aspect-video w-full overflow-hidden bg-black">
<XgPlayer
src={src}
poster={detail.coverImg || ""}
onPlaySuccess={onPlaySuccess}
clickToPlay
className="absolute inset-0"
options={{ ignores: ["cssfullscreen"], fullscreen: { rotateFullscreen: true } }}
/>
)}
<BackButton fallback="/video/hot" className="absolute top-3 left-4 z-10" />
</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]">视频库</p>
<h1 className="text-lg leading-7 font-bold text-white">{title}</h1>
<InfoList rows={infoRows} compact />
<TagLinks tags={tags} compact />
<div className="flex items-center gap-2">
<HlAction kind="like" label={formatCount(likeNum ?? detail.likeNum)} active={liked} onClick={onLike} compact />
<HlAction
kind="collect"
label={formatCount(countCollect ?? detail.countCollect)}
active={collected}
onClick={onCollect}
compact
/>
<HlAction kind="share" label="分享" onClick={onShare} compact />
</div>
{desc ? (
<section className="flex flex-col gap-2 pt-1">
<SectionTitle compact>视频介绍</SectionTitle>
<p className="text-[13px] leading-[22px] whitespace-pre-line text-[#A9A7B3]">{desc}</p>
</section>
) : null}
</article>
{adGrid ?? <AdIcons variant="h5" />}
<VideoRecommend items={related} compact />
{bannerAds ?? <AdBanners variant="h5" />}
</div>
</div>
);
}
+84 -98
View File
@@ -1,28 +1,32 @@
"use client";
import { toast } from "@heroui/react";
import { useEffect, useMemo, useState, type ReactNode } from "react";
import { useEffect, useState, type ReactNode } from "react";
import { useVideoContext } from "@/components/analytics/use-playback-analytics";
import { openLoginDialog } from "@/components/auth/login-dialog";
import { AdBanners, AdIcons } from "@/components/common/ads";
import { CommentPanel, videoCommentTarget } from "@/components/common/comments";
import { DecryptedImage } from "@/components/common/decrypted-image";
import { ActionPill } from "@/components/drama-play/drama-play-page";
import { formatDay, formatDuration } from "@/components/common/media-meta";
import { PcPlayer } from "@/components/drama-play/pc-player";
import { FloatingActions } from "@/components/home/floating-actions";
import {
HlAction,
InfoList,
SectionTitle,
TagLinks,
VideoRecommend,
type InfoRow,
type TagLinkItem,
} from "@/components/media-page/parts";
import { PageBreadcrumb } from "@/components/seo/page-breadcrumb";
import { SeoBreadcrumb } from "@/components/seo/seo-breadcrumb";
import type { ShortDramaItem } from "@/components/short-drama/data";
import { tagPageHref } from "@/components/tag/href";
import { favoriteVideo, getVideoInfo, likeVideo } from "@/lib/api/video-actions";
import { handleUnauthorized } from "@/lib/auth/handle-unauthorized";
import { ensureGuestSession, getAuthToken } from "@/lib/auth/session";
import { IMG_PLACEHOLDER } from "@/lib/image/decrypt";
import type { VideoDetail } from "./data";
import { formatCount, formatWatchNum, type VideoDetail } from "./data";
import { H5VideoPlay } from "./h5-video-play";
import { VideoRelatedAside } from "./related-aside";
import { useReportVideoHistory } from "./use-report-video-history";
async function ensureVideoAuthToken() {
let token = getAuthToken();
@@ -51,7 +55,6 @@ export function VideoPlayPage({
detail,
src,
related = [],
relatedAside,
promo,
adIcons,
adGrid,
@@ -60,7 +63,6 @@ export function VideoPlayPage({
detail: VideoDetail;
src: string;
related?: ShortDramaItem[];
relatedAside?: ReactNode;
promo?: ReactNode;
adIcons?: ReactNode;
adGrid?: ReactNode;
@@ -72,24 +74,6 @@ export function VideoPlayPage({
const [collected, setCollected] = useState(Boolean(detail.isFavorite));
const [countCollect, setCountCollect] = useState(Number(detail.countCollect) || 0);
const [collecting, setCollecting] = useState(false);
const reportWatchHistory = useReportVideoHistory(Number(detail.id));
const tagName = (detail.tags?.[0]?.tagName || detail.tags?.[0]?.name || "").trim();
const videoTrackContext = useMemo(
() => ({
media_id: String(detail.id || ""),
video_id: String(detail.id || ""),
video_title: detail.title || "未命名视频",
video_type_id: "0",
video_type_name: "未分类",
video_content_type: "video",
recommend_trace_id: "",
video_tag_key: tagName ? "tag" : "default",
video_tag_name: tagName || "默认标签",
video_duration: Math.max(0, Math.round(Number(detail.video?.videoTime) || 0)),
}),
[detail.id, detail.title, detail.video?.videoTime, tagName],
);
useVideoContext(videoTrackContext);
const likeFavoriteKey = `${detail.id}:${detail.isLike}:${detail.likeNum}:${detail.isFavorite}:${detail.countCollect}`;
const [likeFavoriteSync, setLikeFavoriteSync] = useState(likeFavoriteKey);
@@ -206,88 +190,92 @@ export function VideoPlayPage({
}
};
return (
<main data-component="video-play-page" className="relative flex-1 bg-[#0B0709]">
<div
aria-hidden="true"
className="pointer-events-none absolute inset-x-0 top-0 hidden h-[1200px] overflow-hidden [mask-image:linear-gradient(180deg,#000_70%,transparent_100%)] lg:block"
>
<DecryptedImage
src={detail.coverImg}
fallback={IMG_PLACEHOLDER}
alt=""
className="size-full scale-110 object-cover opacity-70 blur-[12px]"
/>
<div className="absolute inset-0 bg-[linear-gradient(180deg,rgba(9,5,9,0.32)_0%,rgba(9,5,9,0.56)_55%,rgba(6,5,9,0.94)_100%)]" />
</div>
const title = detail.title || "视频";
const desc = detail.desc?.trim() || "";
const day = formatDay(detail.addedTime);
const duration = formatDuration(detail.video?.videoTime);
const tags: TagLinkItem[] = (detail.tags ?? [])
.map((tag): TagLinkItem | null => {
const name = (tag.tagName || tag.name || "").trim();
if (!name) return null;
const canLink = Boolean(tag.slug?.trim() || tag.id != null);
return {
key: tag.slug || String(tag.id ?? name),
name,
href: canLink ? tagPageHref({ slug: tag.slug, id: tag.id }, "video") : undefined,
};
})
.filter((tag): tag is TagLinkItem => Boolean(tag));
const infoRows: InfoRow[] = [
{ label: "发布", value: day ? <time dateTime={day}>{day}</time> : "" },
{ label: "时长", value: duration },
{ label: "播放", value: formatWatchNum(detail.watchNum) },
{ label: "收藏", value: formatCount(countCollect) },
];
const crumbs = [
{ name: "首页", href: "/" },
{ name: "视频库", href: "/video/hot" },
{ name: title },
];
return (
<main data-component="hl-video-play" className="relative flex-1 bg-[#0C0B10]">
<SeoBreadcrumb items={crumbs} />
<div
data-pc-scale
className="relative mx-auto hidden w-[1700px] flex-col gap-6 pt-6 pb-8 [zoom:var(--page-scale,1)] lg:flex"
className="relative mx-auto hidden w-[1700px] flex-col gap-8 pt-6 pb-14 [zoom:var(--page-scale,1)] lg:flex"
>
<SeoBreadcrumb
items={[
{ name: "首页", href: "/" },
{ name: detail.title || "视频详情" },
]}
/>
<PageBreadcrumb
items={[
{ name: "首页", href: "/" },
{ name: detail.title || "视频详情" },
]}
<PageBreadcrumb items={crumbs} />
<PcPlayer
src={src}
poster={detail.coverImg || ""}
title={title}
locked={false}
dramaTitle={title}
layout="wide"
/>
<div className="flex flex-col gap-4">
<PcPlayer
src={src}
poster={detail.coverImg || ""}
title={detail.title || ""}
locked={false}
dramaTitle={detail.title || ""}
layout="wide"
onPlaySuccess={reportWatchHistory}
analyticsKind="video"
/>
{adIcons ?? <AdIcons variant="pc" labels={false} />}
<section className="flex h-[140px] items-center justify-between gap-10 rounded-xl bg-[rgba(19,15,22,0.9)] px-6 py-5 outline outline-1 -outline-offset-1 outline-[rgba(199,145,89,0.7)]">
<div className="flex min-w-0 flex-col gap-1.5">
<p className="truncate text-[28px] leading-[34px] font-semibold text-white">{detail.title}</p>
<p className="line-clamp-2 text-xs leading-[18px] text-[#9991AB]">{detail.desc}</p>
<article className="grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-10 gap-y-5 border-t-2 border-[#FFB020] pt-8">
<div className="flex min-w-0 flex-col gap-4">
<p className="text-sm leading-5 tracking-[0.2em] text-[#FFB020]">视频库</p>
<h1 className="text-4xl leading-[48px] font-bold text-white">{title}</h1>
<div className="max-w-[900px]">
<InfoList rows={infoRows} />
</div>
<div className="flex shrink-0 gap-3">
<ActionPill
icon="/images/icon_like.svg"
label={liked ? "已点赞" : "点赞"}
active={liked}
onClick={liking ? undefined : toggleLike}
/>
<ActionPill
icon="/images/icon_collect.svg"
label={collected ? "已收藏" : "收藏"}
active={collected}
onClick={collecting ? undefined : toggleCollect}
/>
<ActionPill icon="/images/icon_share.svg" label="分享" onClick={share} />
<ActionPill icon="/images/icon_feedback.svg" label="反馈" href="/feedback" />
</div>
</section>
<div className="flex items-start gap-6">
<CommentPanel variant="play" target={videoCommentTarget(detail.id)} />
{relatedAside ?? <VideoRelatedAside items={related} />}
<TagLinks tags={tags} />
</div>
<div className="flex shrink-0 gap-3 pt-7">
<HlAction kind="like" label={`点赞 ${formatCount(likeNum)}`} active={liked} onClick={liking ? undefined : toggleLike} />
<HlAction
kind="collect"
label={collected ? "已收藏" : "收藏"}
active={collected}
onClick={collecting ? undefined : toggleCollect}
/>
<HlAction kind="share" label="分享" onClick={share} />
</div>
{desc ? (
<section className="col-span-2 flex flex-col gap-3">
<SectionTitle>视频介绍</SectionTitle>
<p className="max-w-[1100px] text-[15px] leading-7 whitespace-pre-line text-[#B5B3BE]">{desc}</p>
</section>
) : null}
</article>
{promo ?? <AdBanners variant="pc" />}
</div>
{adIcons ?? <AdIcons variant="pc" labels={false} />}
<VideoRecommend items={related} />
{promo ?? <AdBanners variant="pc" />}
</div>
<H5VideoPlay
detail={detail}
src={src}
related={related}
infoRows={infoRows.slice(0, 3)}
tags={tags}
liked={liked}
likeNum={likeNum}
collected={collected}
@@ -295,8 +283,6 @@ export function VideoPlayPage({
onLike={liking ? () => undefined : toggleLike}
onCollect={collecting ? () => undefined : toggleCollect}
onShare={share}
commentTarget={videoCommentTarget(detail.id)}
onPlaySuccess={reportWatchHistory}
adGrid={adGrid}
bannerAds={bannerAds}
/>