From 428b4b73d0e922aa1c9027c2a51691215ff7c5ca Mon Sep 17 00:00:00 2001 From: 3970260761 <3970260761@qq.com> Date: Sun, 8 Nov 2026 14:28:59 +0800 Subject: [PATCH] =?UTF-8?q?fixed78:=20=E8=AF=A6=E6=83=85=E9=A1=B5=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E8=B1=86=E7=93=A3=E7=9F=AD=E8=AF=84+=E8=B1=86?= =?UTF-8?q?=E7=93=A3=E8=B7=B3=E8=BD=AC=E6=8C=89=E9=92=AE(=E6=BC=94?= =?UTF-8?q?=E5=91=98/=E8=AF=84=E5=88=86/=E6=BC=94=E5=91=98=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E4=BF=9D=E7=95=99)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- src/app/api/douban-comments/route.ts | 54 ++++++++++++++++++++++ src/app/play/page.tsx | 13 +++++- src/components/VideoMetaExtra.tsx | 68 +++++++++++++++++----------- src/middleware.ts | 3 +- 5 files changed, 111 insertions(+), 29 deletions(-) create mode 100644 src/app/api/douban-comments/route.ts diff --git a/Dockerfile b/Dockerfile index a76f666..a615af5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,7 +51,7 @@ ENV NODE_ENV=production ENV HOSTNAME=0.0.0.0 ENV PORT=3000 ENV DOCKER_ENV=true -ENV NEXT_PUBLIC_SITE_VERSION=fixed77 +ENV NEXT_PUBLIC_SITE_VERSION=fixed78 # 从构建器中复制 standalone 输出 COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ diff --git a/src/app/api/douban-comments/route.ts b/src/app/api/douban-comments/route.ts new file mode 100644 index 0000000..2f719ac --- /dev/null +++ b/src/app/api/douban-comments/route.ts @@ -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: [] }); + } +} diff --git a/src/app/play/page.tsx b/src/app/play/page.tsx index 94d489f..7e6ebad 100644 --- a/src/app/play/page.tsx +++ b/src/app/play/page.tsx @@ -1500,13 +1500,24 @@ function PlayPageClient() {
{/* 第一行:影片标题和操作按钮 */}
-

+

{videoTitle || '影片标题'} {totalEpisodes > 1 && ( {` > 第 ${currentEpisodeIndex + 1} 集`} )} + {detail?.douban_id && ( + + 豆瓣 → + + )}

{/* 跳过设置按钮 */} diff --git a/src/components/VideoMetaExtra.tsx b/src/components/VideoMetaExtra.tsx index 80da8a7..44e88c5 100644 --- a/src/components/VideoMetaExtra.tsx +++ b/src/components/VideoMetaExtra.tsx @@ -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([]); + const [comments, setComments] = useState([]); 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({
)} - {/* 全网热评 Top10 */} + {/* 豆瓣短评 */}
-
- 全网热评 Top10 (来自网上公开影评聚合) +
+ 豆瓣短评 + {doubanId ? ( + + 查看全部 → + + ) : null}
{loading && comments.length === 0 && (
@@ -137,26 +150,29 @@ export default function VideoMetaExtra({
)} {!loading && comments.length === 0 && ( -
暂无全网热评,换个片名或稍后再试。
+
暂无豆瓣短评。
)}
- {comments.map((c, i) => ( - ( +
- - {i + 1} - - {c.title} - {c.source} + {c.avatar ? ( + {c.user} + ) : null} + {c.user} + {c.rating > 0 && ( + {'★'.repeat(c.rating)} + )} + {c.time.slice(0, 10)}
-
{c.content}
-
+
{c.content}
+ {c.location ? ( +
{c.location}
+ ) : null} +
))}
diff --git a/src/middleware.ts b/src/middleware.ts index 4c4bf18..7bab587 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -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).*)', ], };