From af2d257344ece032bdcd4eaac39aba6439b47708 Mon Sep 17 00:00:00 2001 From: shinya Date: Wed, 16 Jul 2025 18:38:05 +0800 Subject: [PATCH] fix: prefer select --- public/manifest.json | 33 +++++++++++++++++++++++++++++++++ src/app/play/page.tsx | 18 ++++++++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 public/manifest.json diff --git a/public/manifest.json b/public/manifest.json new file mode 100644 index 0000000..c1f9fed --- /dev/null +++ b/public/manifest.json @@ -0,0 +1,33 @@ +{ + "name": "MoonTV", + "short_name": "MoonTV", + "description": "影视聚合", + "start_url": "/", + "scope": "/", + "display": "standalone", + "background_color": "#000000", + "apple-mobile-web-app-capable": "yes", + "apple-mobile-web-app-status-bar-style": "black", + "icons": [ + { + "src": "/icons/icon-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "/icons/icon-256x256.png", + "sizes": "256x256", + "type": "image/png" + }, + { + "src": "/icons/icon-384x384.png", + "sizes": "384x384", + "type": "image/png" + }, + { + "src": "/icons/icon-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ] +} diff --git a/src/app/play/page.tsx b/src/app/play/page.tsx index 89a4900..36705f2 100644 --- a/src/app/play/page.tsx +++ b/src/app/play/page.tsx @@ -540,8 +540,23 @@ function PlayPageClient() { } let detailData: SearchResult = sourcesInfo[0]; + // 指定源和id且无需优选 + if (currentSource && currentId && !needPreferRef.current) { + const target = sourcesInfo.find( + (source) => source.source === currentSource && source.id === currentId + ); + if (target) { + detailData = target; + } else { + setError('未找到匹配结果'); + setLoading(false); + return; + } + } + + // 未指定源和 id 或需要优选,且开启优选开关 if ( - ((!currentSource && !currentId) || needPreferRef.current) && + (!currentSource || !currentId || needPreferRef.current) && optimizationEnabled ) { setLoadingStage('preferring'); @@ -550,7 +565,6 @@ function PlayPageClient() { detailData = await preferBestSource(sourcesInfo); } - console.log(sourcesInfo); console.log(detailData.source, detailData.id); setNeedPrefer(false);