fixed78: 详情页改为豆瓣短评+豆瓣跳转按钮(演员/评分/演员搜索保留)
Docker Build & Test / build (push) Canceled after 0s
Docker Build & Test / test (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/amd64) (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/arm/v7) (push) Canceled after 0s
Build & Push Docker image / build-and-push (linux/arm64) (push) Canceled after 0s
Build & Push Docker image / merge-images (push) Canceled after 0s

This commit is contained in:
3970260761 committed 2026-11-08 14:35:25 +08:00
1 parent 8c0a1e209b
commit 428b4b73d0
5 files changed
+111 -29

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
import { NextRequest, NextResponse } from 'next/server';
export const dynamic = 'force-dynamic';
interface DoubanComment {
id: string;
user: string;
avatar: string;
rating: number;
content: string;
time: string;
location: string;
}
// 从豆瓣 rexxar 移动 API 获取短评(热门优先)
export async function GET(req: NextRequest) {
const { searchParams } = new URL(req.url);
const id = (searchParams.get('id') || '').trim();
const sort = (searchParams.get('sort') || 'hot').trim(); // hot | new
const count = Math.min(parseInt(searchParams.get('count') || '10') || 10, 20);
if (!id) return NextResponse.json({ code: 0, msg: '缺少豆瓣ID', list: [] });
const order = sort === 'new' ? 'time' : 'hot';
const url = `https://m.douban.com/rexxar/api/v2/movie/${id}/interests?count=${count}&order_by=${order}&status=done`;
try {
const r = await fetch(url, {
headers: {
'User-Agent':
'Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Mobile/15E148 Safari/604.1',
Referer: `https://m.douban.com/movie/subject/${id}/`,
Accept: 'application/json',
},
signal: AbortSignal.timeout(15000),
});
if (!r.ok) throw new Error(`HTTP ${r.status}`);
const d: any = await r.json();
const list: DoubanComment[] = (Array.isArray(d?.interests) ? d.interests : [])
.map((x: any) => ({
id: String(x?.id || ''),
user: String(x?.user?.name || ''),
avatar: String(x?.user?.avatar || ''),
rating: Number(x?.rating?.value || 0),
content: String(x?.comment || '').trim(),
time: String(x?.create_time || ''),
location: String(x?.ip_location || ''),
}))
.filter((c: DoubanComment) => c.content.length > 0);
return NextResponse.json({ code: 1, msg: 'ok', total: d?.total || list.length, list });
} catch (e: any) {
return NextResponse.json({ code: 0, msg: e?.message || 'fetch fail', list: [] });
}
}
+12 -1
View File
@@ -1500,13 +1500,24 @@ function PlayPageClient() {
<div className='flex flex-col gap-3 py-4 px-5 lg:px-[3rem] 2xl:px-20'>
{/* 第一行:影片标题和操作按钮 */}
<div className='py-1 flex items-center justify-between'>
<h1 className='text-xl font-semibold text-gray-900 dark:text-gray-100'>
<h1 className='text-xl font-semibold text-gray-900 dark:text-gray-100 flex items-center gap-2'>
{videoTitle || '影片标题'}
{totalEpisodes > 1 && (
<span className='text-gray-500 dark:text-gray-400'>
{` > 第 ${currentEpisodeIndex + 1} 集`}
</span>
)}
{detail?.douban_id && (
<a
href={`https://movie.douban.com/subject/${detail.douban_id}/`}
target='_blank'
rel='noreferrer'
title='跳转到豆瓣'
className='inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-green-600 hover:bg-green-700 text-white text-xs font-medium transition-colors'
>
豆瓣 →
</a>
)}
</h1>
{/* 跳过设置按钮 */}
+42 -26
View File
@@ -3,11 +3,14 @@
import Link from 'next/link';
import { useEffect, useState } from 'react';
interface HotComment {
title: string;
interface DoubanComment {
id: string;
user: string;
avatar: string;
rating: number;
content: string;
url: string;
source: string;
time: string;
location: string;
}
// 演员 / 评分 / 全网热评(详情页简介下方)
@@ -32,14 +35,14 @@ export default function VideoMetaExtra({
area?: string;
lang?: string;
}) {
const [comments, setComments] = useState<HotComment[]>([]);
const [comments, setComments] = useState<DoubanComment[]>([]);
const [loading, setLoading] = useState(false);
useEffect(() => {
if (!title) return;
if (!doubanId) return;
let alive = true;
setLoading(true);
fetch(`/api/hot-comments?title=${encodeURIComponent(title)}`)
fetch(`/api/douban-comments?id=${encodeURIComponent(String(doubanId))}`)
.then((r) => r.json())
.then((d) => {
if (alive && d?.code === 1) setComments(d.list || []);
@@ -51,7 +54,7 @@ export default function VideoMetaExtra({
return () => {
alive = false;
};
}, [title]);
}, [doubanId]);
const actors = (actor || '')
.split(/[,,、\/|]/)
@@ -124,10 +127,20 @@ export default function VideoMetaExtra({
</div>
)}
{/* 全网热评 Top10 */}
{/* 豆瓣短评 */}
<div>
<div className='text-sm font-semibold mb-2 opacity-80'>
全网热评 Top10 <span className='font-normal opacity-60'>(来自网上公开影评聚合)</span>
<div className='text-sm font-semibold mb-2 opacity-80 flex items-center gap-2'>
豆瓣短评
{doubanId ? (
<a
href={`https://movie.douban.com/subject/${doubanId}/comments`}
target='_blank'
rel='noreferrer'
className='text-xs text-green-600 hover:underline font-normal'
>
查看全部 →
</a>
) : null}
</div>
{loading && comments.length === 0 && (
<div className='space-y-2'>
@@ -137,26 +150,29 @@ export default function VideoMetaExtra({
</div>
)}
{!loading && comments.length === 0 && (
<div className='text-sm opacity-50'>暂无全网热评,换个片名或稍后再试。</div>
<div className='text-sm opacity-50'>暂无豆瓣短评。</div>
)}
<div className='space-y-2'>
{comments.map((c, i) => (
<a
key={i}
href={c.url}
target='_blank'
rel='noreferrer'
className='block rounded-lg bg-gray-100/80 dark:bg-gray-800/60 p-3 hover:bg-gray-200/80 dark:hover:bg-gray-700/60 transition-colors'
{comments.map((c) => (
<div
key={c.id}
className='rounded-lg bg-gray-100/80 dark:bg-gray-800/60 p-3'
>
<div className='flex items-center gap-2 mb-1'>
<span className='text-xs font-bold text-white bg-amber-500 rounded px-1.5 py-0.5'>
{i + 1}
</span>
<span className='text-sm font-medium truncate flex-1'>{c.title}</span>
<span className='text-xs opacity-50 flex-shrink-0'>{c.source}</span>
{c.avatar ? (
<img src={c.avatar} alt={c.user} className='w-6 h-6 rounded-full' />
) : null}
<span className='text-sm font-medium truncate flex-1'>{c.user}</span>
{c.rating > 0 && (
<span className='text-xs text-amber-500'>{'★'.repeat(c.rating)}</span>
)}
<span className='text-xs opacity-50 flex-shrink-0'>{c.time.slice(0, 10)}</span>
</div>
<div className='text-sm opacity-80 leading-relaxed line-clamp-3'>{c.content}</div>
</a>
<div className='text-sm opacity-80 leading-relaxed'>{c.content}</div>
{c.location ? (
<div className='text-xs opacity-40 mt-1'>{c.location}</div>
) : null}
</div>
))}
</div>
</div>
+2 -1
View File
@@ -170,6 +170,7 @@ function shouldSkipAuth(pathname: string): boolean {
'/api/tvbox',
'/api/filter',
'/api/license-config',
'/api/douban-comments',
];
return skipPaths.some((path) => pathname.startsWith(path));
@@ -178,6 +179,6 @@ function shouldSkipAuth(pathname: string): boolean {
// 配置middleware匹配规则
export const config = {
matcher: [
'/((?!_next/static|_next/image|favicon.ico|login|warning|hls.min.js|mpegts.min.js|api/login|api/register|api/logout|api/cron|api/server-config|api/search|api/detail|api/image-proxy|api/license-config).*)',
'/((?!_next/static|_next/image|favicon.ico|login|warning|hls.min.js|mpegts.min.js|api/login|api/register|api/logout|api/cron|api/server-config|api/search|api/detail|api/image-proxy|api/license-config|api/douban-comments).*)',
],
};