From 145111d3ca6ab2d61753a9ddcfbeea82f58af0cd Mon Sep 17 00:00:00 2001 From: shinya Date: Fri, 22 Aug 2025 19:20:22 +0800 Subject: [PATCH] feat: add play in new tab --- src/components/MobileActionSheet.tsx | 35 +++++++++------------------ src/components/VideoCard.tsx | 36 +++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 25 deletions(-) diff --git a/src/components/MobileActionSheet.tsx b/src/components/MobileActionSheet.tsx index 459fa0a..4f4b75a 100644 --- a/src/components/MobileActionSheet.tsx +++ b/src/components/MobileActionSheet.tsx @@ -321,30 +321,17 @@ const MobileActionSheet: React.FC = ({ {/* 播放源列表 */}
- {(() => { - // 优先显示的播放源 - const prioritySources = ['爱奇艺', '腾讯视频', '优酷', '芒果TV', '哔哩哔哩', 'Netflix', 'Disney+']; - const sortedSources = sources.sort((a, b) => { - const aIndex = prioritySources.indexOf(a); - const bIndex = prioritySources.indexOf(b); - if (aIndex !== -1 && bIndex !== -1) return aIndex - bIndex; - if (aIndex !== -1) return -1; - if (bIndex !== -1) return 1; - return a.localeCompare(b); - }); - - return sortedSources.map((source, index) => ( -
-
- - {source} - -
- )); - })()} + {sources.map((source, index) => ( +
+
+ + {source} + +
+ ))}
diff --git a/src/components/VideoCard.tsx b/src/components/VideoCard.tsx index bd991d0..df500f4 100644 --- a/src/components/VideoCard.tsx +++ b/src/components/VideoCard.tsx @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any,react-hooks/exhaustive-deps,@typescript-eslint/no-empty-function */ -import { Heart, Link, PlayCircleIcon, Trash2 } from 'lucide-react'; +import { ExternalLink, Heart, Link, PlayCircleIcon, Trash2 } from 'lucide-react'; import Image from 'next/image'; import { useRouter } from 'next/navigation'; import React, { @@ -236,6 +236,31 @@ const VideoCard = forwardRef(function VideoCard actualSearchType, ]); + // 新标签页播放处理函数 + const handlePlayInNewTab = useCallback(() => { + if (from === 'douban' || (isAggregate && !actualSource && !actualId)) { + const url = `/play?title=${encodeURIComponent(actualTitle.trim())}${actualYear ? `&year=${actualYear}` : '' + }${actualSearchType ? `&stype=${actualSearchType}` : ''}${isAggregate ? '&prefer=true' : ''}${actualQuery ? `&stitle=${encodeURIComponent(actualQuery.trim())}` : ''}`; + window.open(url, '_blank'); + } else if (actualSource && actualId) { + const url = `/play?source=${actualSource}&id=${actualId}&title=${encodeURIComponent( + actualTitle + )}${actualYear ? `&year=${actualYear}` : ''}${isAggregate ? '&prefer=true' : '' + }${actualQuery ? `&stitle=${encodeURIComponent(actualQuery.trim())}` : '' + }${actualSearchType ? `&stype=${actualSearchType}` : ''}`; + window.open(url, '_blank'); + } + }, [ + from, + actualSource, + actualId, + actualTitle, + actualYear, + isAggregate, + actualQuery, + actualSearchType, + ]); + // 检查搜索结果的收藏状态 const checkSearchFavoriteStatus = useCallback(async () => { if (from === 'search' && !isAggregate && actualSource && actualId && searchFavorited === null) { @@ -327,6 +352,15 @@ const VideoCard = forwardRef(function VideoCard onClick: handleClick, color: 'primary' as const, }); + + // 新标签页播放 + actions.push({ + id: 'play-new-tab', + label: '新标签页播放', + icon: , + onClick: handlePlayInNewTab, + color: 'default' as const, + }); } // 聚合源信息 - 直接在菜单中展示,不需要单独的操作项