移动云盘在线播放

This commit is contained in:
mtvpls
2026-04-26 17:41:56 +08:00
parent d8d7e57eab
commit c877397682
16 changed files with 984 additions and 104 deletions
+95
View File
@@ -3706,14 +3706,19 @@ const NetDiskConfigComponent = ({
const [savePath, setSavePath] = useState('/');
const [playTempSavePath, setPlayTempSavePath] = useState('/');
const [openListTempPath, setOpenListTempPath] = useState('/');
const [mobileEnabled, setMobileEnabled] = useState(false);
const [mobileAuthorization, setMobileAuthorization] = useState('');
useEffect(() => {
const quark = config?.NetDiskConfig?.Quark;
const mobile = config?.NetDiskConfig?.Mobile;
setEnabled(quark?.Enabled || false);
setCookie(quark?.Cookie || '');
setSavePath(quark?.SavePath || '/');
setPlayTempSavePath(quark?.PlayTempSavePath || '/');
setOpenListTempPath(quark?.OpenListTempPath || '/');
setMobileEnabled(mobile?.Enabled || false);
setMobileAuthorization(mobile?.Authorization || '');
}, [config]);
const handleSave = async () => {
@@ -3730,6 +3735,10 @@ const NetDiskConfigComponent = ({
PlayTempSavePath: playTempSavePath,
OpenListTempPath: openListTempPath,
},
Mobile: {
Enabled: mobileEnabled,
Authorization: mobileAuthorization,
},
}),
});
@@ -3772,6 +3781,34 @@ const NetDiskConfigComponent = ({
});
};
const handleValidateMobile = async () => {
await withLoading('validateMobileNetDisk', async () => {
try {
const response = await fetch('/api/admin/netdisk', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
action: 'validate',
provider: 'mobile',
Mobile: {
Authorization: mobileAuthorization,
},
}),
});
const data = await response.json();
if (!response.ok) {
throw new Error(data.error || '校验失败');
}
showSuccess(data.message || '移动云盘验证头格式正常', showAlert);
} catch (error) {
showError(error instanceof Error ? error.message : '校验失败', showAlert);
throw error;
}
});
};
return (
<div className='space-y-6'>
<details className='pt-4 border-t border-gray-200 dark:border-gray-700'>
@@ -3891,6 +3928,64 @@ const NetDiskConfigComponent = ({
</div>
</details>
<details className='pt-4 border-t border-gray-200 dark:border-gray-700'>
<summary className='text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer'>
</summary>
<div className='mt-4 space-y-4'>
<div className='flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700'>
<div>
<h3 className='text-sm font-medium text-gray-900 dark:text-gray-100'>
</h3>
<p className='text-xs text-gray-500 dark:text-gray-400 mt-1'>
</p>
</div>
<label className='relative inline-flex items-center cursor-pointer'>
<input
type='checkbox'
checked={mobileEnabled}
onChange={(e) => setMobileEnabled(e.target.checked)}
className='sr-only peer'
/>
<div className="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-pink-300 dark:peer-focus:ring-pink-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-pink-600"></div>
</label>
</div>
<div>
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2'>
</label>
<textarea
value={mobileAuthorization}
onChange={(e) => setMobileAuthorization(e.target.value)}
disabled={!mobileEnabled}
rows={5}
placeholder='粘贴移动云盘验证头'
className='w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-pink-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed'
/>
</div>
<div className='flex gap-3'>
<button
onClick={handleValidateMobile}
disabled={!mobileEnabled || !mobileAuthorization || isLoading('validateMobileNetDisk')}
className={buttonStyles.primary}
>
{isLoading('validateMobileNetDisk') ? '校验中...' : '校验移动云盘验证头'}
</button>
<button
onClick={handleSave}
disabled={isLoading('saveNetDisk')}
className={buttonStyles.success}
>
{isLoading('saveNetDisk') ? '保存中...' : '保存配置'}
</button>
</div>
</div>
</details>
<AlertModal
isOpen={alertModal.isOpen}
onClose={hideAlert}
+24 -2
View File
@@ -5,6 +5,10 @@ import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig, setCachedConfig } from '@/lib/config';
import { db } from '@/lib/db';
import {
assertMobileAuthorizationHeaderSafe,
normalizeMobileAuthorization,
} from '@/lib/netdisk/mobile.client';
import {
assertQuarkCookieHeaderSafe,
normalizeQuarkCookie,
@@ -40,11 +44,14 @@ export async function POST(request: NextRequest) {
}
const body = await request.json();
const { action, Quark } = body;
const { action, Quark, Mobile, provider } = body;
const adminConfig = await getConfig();
if (action === 'save') {
const normalizedCookie = Quark?.Cookie ? assertQuarkCookieHeaderSafe(Quark.Cookie) : '';
const normalizedMobileAuthorization = Mobile?.Authorization
? assertMobileAuthorizationHeaderSafe(Mobile.Authorization)
: '';
adminConfig.NetDiskConfig = adminConfig.NetDiskConfig || {};
adminConfig.NetDiskConfig.Quark = {
@@ -54,6 +61,10 @@ export async function POST(request: NextRequest) {
PlayTempSavePath: Quark?.PlayTempSavePath || '/',
OpenListTempPath: Quark?.OpenListTempPath || '/',
};
adminConfig.NetDiskConfig.Mobile = {
Enabled: Boolean(Mobile?.Enabled),
Authorization: normalizedMobileAuthorization,
};
await db.saveAdminConfig(adminConfig);
await setCachedConfig(adminConfig);
@@ -62,10 +73,21 @@ export async function POST(request: NextRequest) {
}
if (action === 'validate') {
if (provider === 'mobile') {
if (!Mobile?.Authorization) {
return NextResponse.json({ error: '请先填写移动云盘 Authorization' }, { status: 400 });
}
normalizeMobileAuthorization(Mobile.Authorization);
return NextResponse.json({
success: true,
message: '移动云盘 Authorization 格式正常',
});
}
if (!Quark?.Cookie) {
return NextResponse.json({ error: '请先填写夸克 Cookie' }, { status: 400 });
}
await validateQuarkCookieReadable(normalizeQuarkCookie(Quark.Cookie));
return NextResponse.json({
@@ -0,0 +1,55 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { listMobileShareVideos } from '@/lib/netdisk/mobile.client';
import { createMobileNetdiskSession } from '@/lib/netdisk/mobile-session-cache';
import { NETDISK_MOBILE_SOURCE } from '@/lib/netdisk/source';
import { hasFeaturePermission } from '@/lib/permissions';
export const runtime = 'nodejs';
export async function POST(request: NextRequest) {
try {
const authInfo = getAuthInfoFromCookie(request);
if (!authInfo?.username) {
return NextResponse.json({ error: '未登录' }, { status: 401 });
}
if (!(await hasFeaturePermission(authInfo.username, 'netdisk_temp_play'))) {
return NextResponse.json({ error: '无权限使用临时播放' }, { status: 403 });
}
const { shareUrl, passcode, title } = await request.json();
if (!shareUrl) {
return NextResponse.json({ error: '分享链接不能为空' }, { status: 400 });
}
const config = await getConfig();
const mobileConfig = config.NetDiskConfig?.Mobile;
if (!mobileConfig?.Enabled || !mobileConfig.Authorization) {
return NextResponse.json({ error: '移动云盘未配置或未启用' }, { status: 400 });
}
const result = await listMobileShareVideos(shareUrl, mobileConfig.Authorization);
const session = createMobileNetdiskSession({
title: title || result.title,
shareUrl,
passcode,
files: result.files,
});
return NextResponse.json({
success: true,
source: NETDISK_MOBILE_SOURCE,
id: session.id,
title: title || result.title,
totalFiles: result.files.length,
expiresAt: session.expiresAt,
});
} catch (error) {
return NextResponse.json(
{ error: error instanceof Error ? error.message : '立即播放失败' },
{ status: 500 }
);
}
}
+90
View File
@@ -0,0 +1,90 @@
import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import {
getMobileShareDownloadUrl,
getMobileSharePlayUrl,
listMobileShareVideos,
} from '@/lib/netdisk/mobile.client';
import {
createMobileNetdiskSession,
getMobileNetdiskSession,
parseMobileNetdiskId,
refreshMobileNetdiskSession,
} from '@/lib/netdisk/mobile-session-cache';
export const runtime = 'nodejs';
export async function GET(request: NextRequest) {
try {
const authInfo = getAuthInfoFromCookie(request);
if (!authInfo?.username) {
return NextResponse.json({ error: '未授权' }, { status: 401 });
}
const { searchParams } = new URL(request.url);
const sessionId = searchParams.get('id') || searchParams.get('session');
const episodeIndexRaw = searchParams.get('episodeIndex');
const format = searchParams.get('format');
if (!sessionId || episodeIndexRaw == null) {
return NextResponse.json({ error: '缺少参数' }, { status: 400 });
}
const episodeIndex = Number.parseInt(episodeIndexRaw, 10);
if (!Number.isInteger(episodeIndex) || episodeIndex < 0) {
return NextResponse.json({ error: '无效的 episodeIndex' }, { status: 400 });
}
const config = await getConfig();
const mobileConfig = config.NetDiskConfig?.Mobile;
if (!mobileConfig?.Enabled || !mobileConfig.Authorization) {
return NextResponse.json({ error: '移动云盘未配置或未启用' }, { status: 400 });
}
let session = refreshMobileNetdiskSession(sessionId) || getMobileNetdiskSession(sessionId);
if (!session) {
const payload = parseMobileNetdiskId(sessionId);
const result = await listMobileShareVideos(payload.shareUrl, mobileConfig.Authorization);
session = createMobileNetdiskSession({
title: result.title,
shareUrl: payload.shareUrl,
passcode: payload.passcode,
files: result.files,
});
}
const file = session.files[episodeIndex];
if (!file) {
return NextResponse.json({ error: '播放文件不存在' }, { status: 404 });
}
let url = '';
try {
url = await getMobileSharePlayUrl(
file.contentId,
file.linkID,
mobileConfig.Authorization
);
} catch {
url = await getMobileShareDownloadUrl(
file.contentId,
file.linkID,
mobileConfig.Authorization
);
}
refreshMobileNetdiskSession(sessionId);
if (format === 'json') {
return NextResponse.json({ url, headers: {} });
}
return NextResponse.redirect(url);
} catch (error) {
return NextResponse.json(
{ error: error instanceof Error ? error.message : '获取播放地址失败' },
{ status: 500 }
);
}
}
@@ -3,6 +3,7 @@ import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { createQuarkInstantPlayFolder } from '@/lib/netdisk/quark.client';
import { NETDISK_QUARK_SOURCE } from '@/lib/netdisk/source';
import { hasFeaturePermission } from '@/lib/permissions';
import { base58Encode } from '@/lib/utils';
@@ -76,7 +77,7 @@ export async function POST(request: NextRequest) {
return NextResponse.json({
success: true,
source: 'quark-temp',
source: NETDISK_QUARK_SOURCE,
id: base58Encode(openlistFolderPath),
title: title || result.folderName,
openlistFolderPath,
+82 -3
View File
@@ -6,6 +6,13 @@ import { getAuthInfoFromCookie } from '@/lib/auth';
import { getAvailableApiSites, getCacheTime, getConfig } from '@/lib/config';
import { getDetailFromApiV2 } from '@/lib/downstream';
import { getProxyToken } from '@/lib/emby-token';
import {
createMobileNetdiskSession,
getMobileNetdiskSession,
parseMobileNetdiskId,
refreshMobileNetdiskSession,
} from '@/lib/netdisk/mobile-session-cache';
import { LEGACY_QUARK_TEMP_SOURCE, NETDISK_MOBILE_SOURCE, NETDISK_QUARK_SOURCE, normalizeNetdiskSource } from '@/lib/netdisk/source';
import {
executeSavedSourceScript,
normalizeScriptDetailResult,
@@ -27,7 +34,7 @@ export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url);
const id = searchParams.get('id');
const sourceCode = searchParams.get('source');
const sourceCode = normalizeNetdiskSource(searchParams.get('source'));
const fileName = searchParams.get('fileName'); // 小雅源:用户点击的文件名
const title = searchParams.get('title');
@@ -275,7 +282,79 @@ export async function GET(request: NextRequest) {
}
}
if (sourceCode === 'quark-temp') {
if (sourceCode === NETDISK_MOBILE_SOURCE) {
try {
const config = await getConfig();
const mobileConfig = config.NetDiskConfig?.Mobile;
if (!mobileConfig?.Enabled || !mobileConfig.Authorization) {
throw new Error('移动云盘未配置或未启用');
}
let session = refreshMobileNetdiskSession(id) || getMobileNetdiskSession(id);
if (!session) {
const payload = parseMobileNetdiskId(id);
const { listMobileShareVideos } = await import('@/lib/netdisk/mobile.client');
const result = await listMobileShareVideos(payload.shareUrl, mobileConfig.Authorization);
session = createMobileNetdiskSession({
title: title || result.title,
shareUrl: payload.shareUrl,
passcode: payload.passcode,
files: result.files,
});
}
if (!session) {
throw new Error('移动云盘播放信息恢复失败');
}
const mobileSession = session;
const { parseVideoFileName } = await import('@/lib/video-parser');
const parsedFiles = mobileSession.files.map((file, index) => {
const parsed = parseVideoFileName(file.name);
return {
...file,
originalIndex: index,
sortEpisode: parsed.episode || index + 1,
isOVA: parsed.isOVA,
displayTitle:
parsed.title ||
(parsed.episode ? `${parsed.episode}` : file.name),
};
}).sort((a, b) => {
if (a.isOVA && !b.isOVA) return 1;
if (!a.isOVA && b.isOVA) return -1;
return a.sortEpisode !== b.sortEpisode
? a.sortEpisode - b.sortEpisode
: a.name.localeCompare(b.name, 'zh-Hans-CN', {
numeric: true,
sensitivity: 'base',
});
});
const episodes = parsedFiles.map((file) => (
`/api/netdisk/mobile/play?id=${encodeURIComponent(mobileSession.id)}&episodeIndex=${file.originalIndex}`
));
return NextResponse.json({
source: NETDISK_MOBILE_SOURCE,
source_name: '移动云盘',
id: mobileSession.id,
title: title || mobileSession.title,
poster: '',
year: '',
douban_id: 0,
desc: `移动云盘分享:${mobileSession.shareUrl}`,
episodes,
episodes_titles: parsedFiles.map((file) => file.displayTitle),
proxyMode: false,
});
} catch (error) {
return NextResponse.json(
{ error: (error as Error).message },
{ status: 500 }
);
}
}
if (sourceCode === NETDISK_QUARK_SOURCE || sourceCode === LEGACY_QUARK_TEMP_SOURCE) {
try {
const config = await getConfig();
const openListConfig = config.OpenListConfig;
@@ -390,7 +469,7 @@ export async function GET(request: NextRequest) {
});
return NextResponse.json({
source: 'quark-temp',
source: NETDISK_QUARK_SOURCE,
source_name: '夸克临时播放',
id,
title: title || folderPath.split('/').filter(Boolean).pop() || '夸克临时播放',
+57 -39
View File
@@ -8,8 +8,8 @@ import { Suspense, useEffect, useMemo, useRef, useState } from 'react';
import { getAuthInfoFromBrowserCookie } from '@/lib/auth';
import {
convertDanmakuFormat,
clearDanmakuCacheByTitle,
convertDanmakuFormat,
getDanmakuById,
getDanmakuFromCache,
getEpisodes,
@@ -54,12 +54,13 @@ import {
pruneLocalEpisodeProgressStorage,
saveLocalEpisodeProgress,
} from '@/lib/episode-progress';
import { getTMDBImageUrl } from '@/lib/tmdb.search';
import { isNetdiskSource, normalizeNetdiskSource } from '@/lib/netdisk/source';
import {
getRecommendationCache,
recommendationCacheKeys,
setRecommendationCache,
} from '@/lib/recommendations/cache';
import { getTMDBImageUrl } from '@/lib/tmdb.search';
import { DanmakuFilterConfig, EpisodeFilterConfig, SearchResult } from '@/lib/types';
import { base58Decode, getVideoResolutionFromM3u8, processImageUrl } from '@/lib/utils';
import { useEnableAIComments } from '@/hooks/useEnableAIComments';
@@ -605,27 +606,28 @@ function PlayPageClient() {
// 纠错后的描述信息(用于显示,不触发 detail 更新)
const [correctedDesc, setCorrectedDesc] = useState<string>('');
const [quarkTempTMDBMeta, setQuarkTempTMDBMeta] = useState<{
const [netdiskTMDBMeta, setNetdiskTMDBMeta] = useState<{
desc?: string;
poster?: string;
year?: string;
tmdbId?: number;
} | null>(null);
const [pendingQuarkTempTMDBData, setPendingQuarkTempTMDBData] = useState<any | null>(null);
const [pendingNetdiskTMDBData, setPendingNetdiskTMDBData] = useState<any | null>(null);
// 当前源和ID - source 直接存储完整格式(如 'emby_wumei' 或 'emby'
const [currentSource, setCurrentSource] = useState(searchParams.get('source') || '');
const [currentSource, setCurrentSource] = useState(normalizeNetdiskSource(searchParams.get('source')) || '');
const [currentId, setCurrentId] = useState(searchParams.get('id') || '');
const [fileName] = useState(searchParams.get('fileName') || ''); // 小雅源:用户点击的文件名
const isDirectPlay = currentSource === 'directplay';
useEffect(() => {
setQuarkTempTMDBMeta(null);
setPendingQuarkTempTMDBData(null);
setNetdiskTMDBMeta(null);
setPendingNetdiskTMDBData(null);
}, [currentSource, currentId]);
// 解析 source 参数以获取 embyKey(仅用于 API 调用)
const parseSourceForApi = (source: string): { source: string; embyKey?: string } => {
source = normalizeNetdiskSource(source);
if (source.startsWith('emby_')) {
const key = source.substring(5);
return { source: 'emby', embyKey: key };
@@ -1300,19 +1302,22 @@ function PlayPageClient() {
const populatePlayMetadataFromTMDB = (tmdbData: any) => {
const currentDetail = detailRef.current;
if (!currentDetail || currentDetail.source !== 'quark-temp') {
setPendingQuarkTempTMDBData(tmdbData);
if (!currentDetail || !isNetdiskSource(currentDetail.source)) {
setPendingNetdiskTMDBData(tmdbData);
return;
}
const tmdbYear = tmdbData.releaseDate?.split('-')[0] || '';
const shouldReplaceDesc = !currentDetail.desc || currentDetail.desc.startsWith('临时播放目录:');
const shouldReplaceDesc =
!currentDetail.desc ||
currentDetail.desc.startsWith('临时播放目录:') ||
currentDetail.desc.startsWith('移动云盘分享:');
const resolvedTmdbId = typeof tmdbData.tmdbId === 'string'
? Number(String(tmdbData.tmdbId).split(':')[1] || 0)
: tmdbData.tmdbId;
setQuarkTempTMDBMeta({
setNetdiskTMDBMeta({
desc: shouldReplaceDesc ? (tmdbData.overview || currentDetail.desc) : currentDetail.desc,
poster: currentDetail.poster || tmdbData.poster || '',
year: currentDetail.year || tmdbYear,
@@ -1320,7 +1325,7 @@ function PlayPageClient() {
});
setDetail((prev) => {
if (!prev || prev.source !== 'quark-temp') {
if (!prev || !isNetdiskSource(prev.source)) {
return prev;
}
@@ -1381,25 +1386,32 @@ function PlayPageClient() {
useEffect(() => {
if (
pendingQuarkTempTMDBData &&
detail?.source === 'quark-temp'
pendingNetdiskTMDBData &&
isNetdiskSource(detail?.source)
) {
const pending = pendingQuarkTempTMDBData;
setPendingQuarkTempTMDBData(null);
const currentDetail = detail;
if (!currentDetail) {
return;
}
const pending = pendingNetdiskTMDBData;
setPendingNetdiskTMDBData(null);
const tmdbYear = pending.releaseDate?.split('-')[0] || '';
const shouldReplaceDesc = !detail.desc || detail.desc.startsWith('临时播放目录:');
const shouldReplaceDesc =
!currentDetail.desc ||
currentDetail.desc.startsWith('临时播放目录:') ||
currentDetail.desc.startsWith('移动云盘分享:');
const resolvedTmdbId = typeof pending.tmdbId === 'string'
? Number(String(pending.tmdbId).split(':')[1] || 0)
: pending.tmdbId;
setQuarkTempTMDBMeta({
desc: shouldReplaceDesc ? (pending.overview || detail.desc) : detail.desc,
poster: detail.poster || pending.poster || '',
year: detail.year || tmdbYear,
tmdbId: detail.tmdb_id || resolvedTmdbId,
setNetdiskTMDBMeta({
desc: shouldReplaceDesc ? (pending.overview || currentDetail.desc) : currentDetail.desc,
poster: currentDetail.poster || pending.poster || '',
year: currentDetail.year || tmdbYear,
tmdbId: currentDetail.tmdb_id || resolvedTmdbId,
});
setDetail((prev) => prev && prev.source === 'quark-temp' ? {
setDetail((prev) => prev && isNetdiskSource(prev.source) ? {
...prev,
poster: prev.poster || pending.poster || '',
year: prev.year || tmdbYear,
@@ -1407,17 +1419,17 @@ function PlayPageClient() {
tmdb_id: prev.tmdb_id || resolvedTmdbId,
} : prev);
if (pending.poster && !detail.poster) {
if (pending.poster && !currentDetail.poster) {
setVideoCover(processImageUrl(pending.poster));
}
if (tmdbYear && !detail.year) {
if (tmdbYear && !currentDetail.year) {
setVideoYear(tmdbYear);
}
if (pending.overview) {
setCorrectedDesc(pending.overview);
}
}
}, [pendingQuarkTempTMDBData, detail]);
}, [pendingNetdiskTMDBData, detail]);
// 视频播放地址
const [videoUrl, setVideoUrl] = useState('');
@@ -1535,7 +1547,7 @@ function PlayPageClient() {
!isM3u8LikeUrl(videoUrl) &&
(
detail.source === 'openlist' ||
detail.source === 'quark-temp' ||
isNetdiskSource(detail.source) ||
detail.source === 'xiaoya' ||
detail.source.startsWith('emby')
)
@@ -4165,7 +4177,7 @@ function PlayPageClient() {
// 监听 URL 参数变化,处理换源和换视频(用于房员跟随房主操作)
useEffect(() => {
const urlSource = searchParams.get('source');
const urlSource = normalizeNetdiskSource(searchParams.get('source'));
const urlId = searchParams.get('id');
// 只在URL参数存在且与当前状态不同时才处理
@@ -9639,12 +9651,12 @@ function PlayPageClient() {
</span>
)}
{/* 优先使用 doubanYear,如果没有则使用 detail.year 或 videoYear */}
{(doubanYear || quarkTempTMDBMeta?.year || detail?.year || videoYear) && (
<span>{doubanYear || quarkTempTMDBMeta?.year || detail?.year || videoYear}</span>
{(doubanYear || netdiskTMDBMeta?.year || detail?.year || videoYear) && (
<span>{doubanYear || netdiskTMDBMeta?.year || detail?.year || videoYear}</span>
)}
{detail?.source_name && (
<span
className={`relative group cursor-pointer border px-2 py-[1px] rounded ${detail.source === 'xiaoya' ? 'border-blue-500' : detail.source === 'quark-temp' ? 'border-purple-500' : detail.source === 'openlist' || detail.source === 'emby' || detail.source?.startsWith('emby_') ? 'border-yellow-500' : 'border-gray-500/60'
className={`relative group cursor-pointer border px-2 py-[1px] rounded ${detail.source === 'xiaoya' ? 'border-blue-500' : isNetdiskSource(detail.source) ? 'border-purple-500' : detail.source === 'openlist' || detail.source === 'emby' || detail.source?.startsWith('emby_') ? 'border-yellow-500' : 'border-gray-500/60'
}`}
onClick={fetchCurrentSourceVideoInfo}
>
@@ -9664,7 +9676,7 @@ function PlayPageClient() {
{detail?.type_name && <span>{detail.type_name}</span>}
</div>
{/* 剧情简介 */}
{(doubanCardSubtitle || quarkTempTMDBMeta?.desc || correctedDesc || detail?.desc) && (
{(doubanCardSubtitle || netdiskTMDBMeta?.desc || correctedDesc || detail?.desc) && (
<div
className={`mt-0 text-base leading-relaxed opacity-90 overflow-y-auto pr-2 flex-1 min-h-0 scrollbar-hide ${tmdbBackdrop ? 'text-white' : ''}`}
style={{ whiteSpace: 'pre-line' }}
@@ -9675,7 +9687,7 @@ function PlayPageClient() {
{doubanCardSubtitle}
</div>
)}
{quarkTempTMDBMeta?.desc || correctedDesc || detail?.desc}
{netdiskTMDBMeta?.desc || correctedDesc || detail?.desc}
</div>
)}
</div>
@@ -9720,9 +9732,15 @@ function PlayPageClient() {
)}
</>
) : (
<span className='text-gray-600 dark:text-gray-400'>
</span>
isNetdiskSource(detail?.source) ? (
<div className='flex flex-col items-center justify-center text-gray-500 dark:text-gray-400'>
<Cloud className='w-16 h-16 opacity-80' />
</div>
) : (
<span className='text-gray-600 dark:text-gray-400'>
</span>
)
)}
</div>
</div>
@@ -9929,7 +9947,7 @@ function PlayPageClient() {
// 特殊源使用 tmdb,其他使用 cms(通过 doubanId
// 如果有豆瓣ID且不为0,传入doubanId
detail.source === 'openlist' ||
detail.source === 'quark-temp' ||
isNetdiskSource(detail.source) ||
detail.source?.startsWith('emby') ||
detail.source === 'xiaoya'
? undefined
@@ -9940,7 +9958,7 @@ function PlayPageClient() {
tmdbId={
// 特殊源使用 tmdb
detail.source === 'openlist' ||
detail.source === 'quark-temp' ||
isNetdiskSource(detail.source) ||
detail.source?.startsWith('emby') ||
detail.source === 'xiaoya'
? detail.tmdb_id
@@ -9952,7 +9970,7 @@ function PlayPageClient() {
// 非特殊源使用 cms 数据
// 但如果有豆瓣ID且不为0,则不传入cmsData,优先使用豆瓣数据
detail.source !== 'openlist' &&
detail.source !== 'quark-temp' &&
!isNetdiskSource(detail.source) &&
!detail.source?.startsWith('emby') &&
detail.source !== 'xiaoya' &&
!(detail.douban_id && detail.douban_id !== 0)
+49 -37
View File
@@ -962,40 +962,6 @@ function SearchPageClient() {
}, [activeTab]);
useEffect(() => {
// 从 URL 读取搜索类型参数
const typeParam = searchParams.get('type');
const query = searchParams.get('q');
if (
(typeParam === 'pansou' && netdiskSearchEnabled) ||
(typeParam === 'acg' && magnetSearchEnabled)
) {
setActiveTab(typeParam);
// 如果有搜索关键词且显示结果,触发对应的搜索
if (query && query.trim()) {
setSearchQuery(query);
setShowResults(true);
// 延迟触发搜索,确保组件已经切换到正确的标签页
setTimeout(() => {
if (typeParam === 'pansou') {
setTriggerPansouSearch((prev) => !prev);
} else if (typeParam === 'acg') {
setTriggerAcgSearch((prev) => !prev);
}
}, 100);
}
} else if (typeParam === 'video') {
setActiveTab('video');
} else if (!typeParam && query) {
// 如果没有 type 参数但有查询,默认为 video
setActiveTab('video');
}
// 无搜索参数时聚焦搜索框
!searchParams.get('q') && document.getElementById('searchInput')?.focus();
// 获取用户权限
const authInfo = getAuthInfoFromBrowserCookie();
setUserRole(authInfo?.role || null);
@@ -1095,6 +1061,31 @@ function SearchPageClient() {
};
}, []);
useEffect(() => {
const typeParam = searchParams.get('type');
const query = searchParams.get('q');
if (typeParam === 'pansou') {
if (netdiskSearchEnabled) {
setActiveTab('pansou');
} else {
setActiveTab('video');
}
} else if (typeParam === 'acg') {
if (magnetSearchEnabled) {
setActiveTab('acg');
} else {
setActiveTab('video');
}
} else {
setActiveTab('video');
}
if (!query) {
document.getElementById('searchInput')?.focus();
}
}, [searchParams, netdiskSearchEnabled, magnetSearchEnabled]);
useEffect(() => {
// 等待转换器初始化完成
if (!converterReady) {
@@ -1348,7 +1339,27 @@ function SearchPageClient() {
setShowResults(false);
setShowSuggestions(false);
}
}, [searchParams, forceRefresh, converterReady, netdiskSearchEnabled, magnetSearchEnabled]);
}, [searchParams, forceRefresh, converterReady]);
useEffect(() => {
const typeParam = searchParams.get('type');
const query = searchParams.get('q');
if (!query || !query.trim()) return;
if (typeParam === 'pansou' && netdiskSearchEnabled) {
setSearchQuery(query);
setShowResults(true);
setTimeout(() => {
setTriggerPansouSearch((prev) => !prev);
}, 100);
} else if (typeParam === 'acg' && magnetSearchEnabled) {
setSearchQuery(query);
setShowResults(true);
setTimeout(() => {
setTriggerAcgSearch((prev) => !prev);
}, 100);
}
}, [searchParams, netdiskSearchEnabled, magnetSearchEnabled]);
// 组件卸载时,关闭可能存在的连接
useEffect(() => {
@@ -1553,8 +1564,9 @@ function SearchPageClient() {
setSearchQuery(trimmed);
setShowResults(true);
setShowSuggestions(false);
router.push(`/search?q=${encodeURIComponent(trimmed)}`);
router.push(
`/search?q=${encodeURIComponent(trimmed)}&type=${activeTab}`
);
}}
/>
</div>