整体UI调整
This commit is contained in:
@@ -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}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user