添加视频循环模式和下载功能,优化页面元数据和样式

This commit is contained in:
2025-10-21 18:36:17 +08:00
parent 200283b21b
commit 5c98257366
6 changed files with 246 additions and 71 deletions
+32
View File
@@ -1,6 +1,7 @@
import { prisma } from "@/lib/prisma";
import BackButton from "@/app/components/BackButton";
import AwemeDetailClient from "./Client";
import type { Metadata } from "next";
function ms(v?: number | null) {
if (!v) return "";
@@ -10,6 +11,37 @@ function ms(v?: number | null) {
return `${m}:${r.toString().padStart(2, "0")}`;
}
export async function generateMetadata({ params }: { params: Promise<{ awemeId: string }> }): Promise<Metadata> {
const id = (await params).awemeId;
const [video, post] = await Promise.all([
prisma.video.findUnique({
where: { aweme_id: id },
select: { desc: true, author: { select: { nickname: true } } },
}),
prisma.imagePost.findUnique({
where: { aweme_id: id },
select: { desc: true, author: { select: { nickname: true } } },
})
]);
const data = video || post;
if (!data) {
return {
title: "作品不存在",
};
}
const desc = data.desc || "查看作品详情";
const author = data.author.nickname;
const title = desc.length > 50 ? `${desc.slice(0, 50)}... - ${author}` : `${desc} - ${author}`;
return {
title,
description: desc,
};
}
export default async function AwemeDetail({ params }: { params: Promise<{ awemeId: string }> }) {
const id = (await params).awemeId;