diff --git a/src/app/api/douban/route.ts b/src/app/api/douban/route.ts
index d6871bd..289e961 100644
--- a/src/app/api/douban/route.ts
+++ b/src/app/api/douban/route.ts
@@ -5,6 +5,7 @@ import { DoubanItem, DoubanResult } from '@/lib/types';
interface DoubanApiResponse {
subjects: Array<{
+ id: string;
title: string;
cover: string;
rate: string;
@@ -95,6 +96,7 @@ export async function GET(request: Request) {
// 转换数据格式
const list: DoubanItem[] = doubanData.subjects.map((item) => ({
+ id: item.id,
title: item.title,
poster: item.cover,
rate: item.rate,
@@ -149,21 +151,23 @@ function handleTop250(pageStart: number) {
// 获取 HTML 内容
const html = await fetchResponse.text();
- // 使用正则表达式提取电影信息
+ // 通过正则同时捕获影片 id、标题、封面以及评分
const moviePattern =
- /
[\s\S]*?
![]()
]+alt="([^"]+)"[^>]*src="([^"]+)"[\s\S]*?
]*>([^<]+)<\/span>[\s\S]*?<\/div>/g;
+ /[\s\S]*?
]+href="https?:\/\/movie\.douban\.com\/subject\/(\d+)\/"[\s\S]*?
]+alt="([^"]+)"[^>]*src="([^"]+)"[\s\S]*?]*>([^<]*)<\/span>[\s\S]*?<\/div>/g;
const movies: DoubanItem[] = [];
let match;
while ((match = moviePattern.exec(html)) !== null) {
- const title = match[1];
- const cover = match[2];
- const rate = match[3] || '';
+ const id = match[1];
+ const title = match[2];
+ const cover = match[3];
+ const rate = match[4] || '';
// 处理图片 URL,确保使用 HTTPS
const processedCover = cover.replace(/^http:/, 'https:');
movies.push({
+ id: id,
title: title,
poster: processedCover,
rate: rate,
diff --git a/src/app/douban/page.tsx b/src/app/douban/page.tsx
index 86b20a1..61f793d 100644
--- a/src/app/douban/page.tsx
+++ b/src/app/douban/page.tsx
@@ -199,6 +199,7 @@ function DoubanPageClient() {
doubanData.map((item, index) => (
{
+const DemoCard = ({ id, title, poster, rate }: DemoCardProps) => {
const [hover, setHover] = useState(false);
const router = useRouter();
@@ -98,6 +99,18 @@ const DemoCard = ({ title, poster, rate }: DemoCardProps) => {
+ {/* 顶部左侧 🔗 链接按钮 */}
+ e.stopPropagation()}
+ className='absolute top-2 left-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200'
+ >
+
+
+
+
{/* 信息层 */}
diff --git a/src/lib/types.ts b/src/lib/types.ts
index 41f5e28..d9abe6a 100644
--- a/src/lib/types.ts
+++ b/src/lib/types.ts
@@ -32,6 +32,7 @@ export interface SearchResult {
}
export interface DoubanItem {
+ id: string;
title: string;
poster: string;
rate: string;