From 6445f7c704bac529ff8b6d9092a94b2dc1163240 Mon Sep 17 00:00:00 2001 From: mtvpls Date: Thu, 7 May 2026 10:29:50 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E7=9B=98=E9=93=BE=E6=8E=A5=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E6=97=A0=E6=95=88=E9=93=BE=E6=8E=A5=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=BD=AE=E4=BA=8E=E5=BA=95=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/PansouSearch.tsx | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/components/PansouSearch.tsx b/src/components/PansouSearch.tsx index 7a57ccb..fbcbb79 100644 --- a/src/components/PansouSearch.tsx +++ b/src/components/PansouSearch.tsx @@ -332,7 +332,7 @@ export default function PansouSearch({ const data = await response.json(); if (!response.ok) { - throw new Error(data.error || '立即播放失败'); + throw new Error(data.error || '播放失败'); } router.push( @@ -340,7 +340,7 @@ export default function PansouSearch({ ); } catch (err: any) { setToast({ - message: err?.message || '立即播放失败', + message: err?.message || '播放失败', type: 'error', onClose: () => setToast(null), }); @@ -426,6 +426,24 @@ export default function PansouSearch({ return task?.results?.[url] || null; }; + const getSortedLinks = (cloudType: string, links: PansouLink[]) => { + return links + .map((link, index) => ({ + link, + index, + checkResult: getCheckResultForUrl(cloudType, link.url), + })) + .sort((a, b) => { + const aInvalid = a.checkResult?.status === 'invalid' ? 1 : 0; + const bInvalid = b.checkResult?.status === 'invalid' ? 1 : 0; + if (aInvalid !== bInvalid) { + return aInvalid - bInvalid; + } + return a.index - b.index; + }) + .map(({ link }) => link); + }; + const renderBody = () => { if (loading) { return ( @@ -526,6 +544,7 @@ export default function PansouSearch({ {filteredCloudTypes.map((cloudType) => { const links = results.merged_by_type?.[cloudType]; if (!links || links.length === 0) return null; + const sortedLinks = getSortedLinks(cloudType, links); const typeName = CLOUD_TYPE_NAMES[cloudType] || cloudType; const typeColor = CLOUD_TYPE_COLORS[cloudType] || CLOUD_TYPE_COLORS.others; @@ -581,7 +600,7 @@ export default function PansouSearch({ {/* 链接列表 */}
- {links.map((link: PansouLink, index: number) => ( + {sortedLinks.map((link: PansouLink, index: number) => (
handleNetdiskInstantPlay(cloudType, link)} disabled={playingUrl === link.url} className='px-2 py-1 rounded-md bg-green-600 hover:bg-green-700 text-white text-xs transition-colors disabled:opacity-60' - title='立即播放' + title='播放' > - {playingUrl === link.url ? '处理中...' : '立即播放'} + {playingUrl === link.url ? '处理中...' : '播放'} {cloudType === 'quark' && (