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({ {/* 链接列表 */}