私人影库增加手动纠错
This commit is contained in:
@@ -3310,6 +3310,8 @@ const OpenListConfigComponent = ({
|
||||
)}
|
||||
<button
|
||||
onClick={() => {
|
||||
console.log('Video object:', video);
|
||||
console.log('Video poster field:', video.poster);
|
||||
setSelectedVideo(video);
|
||||
setCorrectDialogOpen(true);
|
||||
}}
|
||||
@@ -3356,6 +3358,17 @@ const OpenListConfigComponent = ({
|
||||
onClose={() => setCorrectDialogOpen(false)}
|
||||
videoKey={selectedVideo.id}
|
||||
currentTitle={selectedVideo.title}
|
||||
currentVideo={{
|
||||
tmdbId: selectedVideo.tmdbId,
|
||||
doubanId: selectedVideo.doubanId,
|
||||
poster: selectedVideo.poster,
|
||||
releaseDate: selectedVideo.releaseDate,
|
||||
overview: selectedVideo.overview,
|
||||
voteAverage: selectedVideo.voteAverage,
|
||||
mediaType: selectedVideo.mediaType,
|
||||
seasonNumber: selectedVideo.seasonNumber,
|
||||
seasonName: selectedVideo.seasonName,
|
||||
}}
|
||||
onCorrect={handleCorrectSuccess}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -30,6 +30,7 @@ export async function POST(request: NextRequest) {
|
||||
const {
|
||||
key,
|
||||
tmdbId,
|
||||
doubanId,
|
||||
title,
|
||||
posterPath,
|
||||
releaseDate,
|
||||
@@ -40,9 +41,10 @@ export async function POST(request: NextRequest) {
|
||||
seasonName,
|
||||
} = body;
|
||||
|
||||
if (!key || !tmdbId) {
|
||||
// 只验证 key 和 title 是必需的
|
||||
if (!key || !title) {
|
||||
return NextResponse.json(
|
||||
{ error: '缺少必要参数' },
|
||||
{ error: '缺少必要参数 (key 或 title)' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
@@ -111,7 +113,8 @@ export async function POST(request: NextRequest) {
|
||||
// 更新视频信息
|
||||
metaInfo.folders[key] = {
|
||||
folderName: folderName,
|
||||
tmdb_id: tmdbId,
|
||||
tmdb_id: tmdbId || null,
|
||||
douban_id: doubanId || null,
|
||||
title: title,
|
||||
poster_path: posterPath,
|
||||
release_date: releaseDate || '',
|
||||
@@ -120,8 +123,8 @@ export async function POST(request: NextRequest) {
|
||||
media_type: mediaType,
|
||||
last_updated: Date.now(),
|
||||
failed: false, // 纠错后标记为成功
|
||||
season_number: seasonNumber, // 季度编号(可选)
|
||||
season_name: seasonName, // 季度名称(可选)
|
||||
season_number: seasonNumber, // 季度编号(可选)
|
||||
season_name: seasonName, // 季度名称(可选)
|
||||
};
|
||||
|
||||
// 保存 metainfo 到数据库
|
||||
|
||||
@@ -130,6 +130,7 @@ export async function GET(request: NextRequest) {
|
||||
id: key,
|
||||
folder: info.folderName,
|
||||
tmdbId: info.tmdb_id,
|
||||
doubanId: info.douban_id,
|
||||
title: info.title,
|
||||
poster: getTMDBImageUrl(info.poster_path),
|
||||
releaseDate: info.release_date,
|
||||
|
||||
@@ -37,6 +37,17 @@ interface CorrectDialogProps {
|
||||
onClose: () => void;
|
||||
videoKey: string;
|
||||
currentTitle: string;
|
||||
currentVideo?: {
|
||||
tmdbId?: number;
|
||||
doubanId?: string;
|
||||
poster?: string;
|
||||
releaseDate?: string;
|
||||
overview?: string;
|
||||
voteAverage?: number;
|
||||
mediaType?: 'movie' | 'tv';
|
||||
seasonNumber?: number;
|
||||
seasonName?: string;
|
||||
};
|
||||
onCorrect: () => void;
|
||||
}
|
||||
|
||||
@@ -45,6 +56,7 @@ export default function CorrectDialog({
|
||||
onClose,
|
||||
videoKey,
|
||||
currentTitle,
|
||||
currentVideo,
|
||||
onCorrect,
|
||||
}: CorrectDialogProps) {
|
||||
const [searchQuery, setSearchQuery] = useState(currentTitle);
|
||||
@@ -59,6 +71,21 @@ export default function CorrectDialog({
|
||||
const [loadingSeasons, setLoadingSeasons] = useState(false);
|
||||
const [showSeasonSelection, setShowSeasonSelection] = useState(false);
|
||||
|
||||
// 手动输入相关状态
|
||||
const [showManualInput, setShowManualInput] = useState(false);
|
||||
const [manualData, setManualData] = useState({
|
||||
title: '',
|
||||
tmdbId: '',
|
||||
doubanId: '',
|
||||
posterPath: '',
|
||||
releaseDate: '',
|
||||
overview: '',
|
||||
voteAverage: '',
|
||||
mediaType: 'movie' as 'movie' | 'tv',
|
||||
seasonNumber: '',
|
||||
seasonName: '',
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
setSearchQuery(currentTitle);
|
||||
@@ -67,9 +94,31 @@ export default function CorrectDialog({
|
||||
setSelectedResult(null);
|
||||
setSeasons([]);
|
||||
setShowSeasonSelection(false);
|
||||
setShowManualInput(false);
|
||||
// 不要在这里重置 manualData,因为它会在 handleShowManualInput 中被设置
|
||||
}
|
||||
}, [isOpen, currentTitle]);
|
||||
|
||||
// 当切换到手动输入模式时,自动填充数据
|
||||
useEffect(() => {
|
||||
if (showManualInput && isOpen) {
|
||||
const newManualData = {
|
||||
title: currentTitle,
|
||||
tmdbId: currentVideo?.tmdbId ? String(currentVideo.tmdbId) : '',
|
||||
doubanId: currentVideo?.doubanId || '',
|
||||
posterPath: currentVideo?.poster || '',
|
||||
releaseDate: currentVideo?.releaseDate || '',
|
||||
overview: currentVideo?.overview || '',
|
||||
voteAverage: currentVideo?.voteAverage ? String(currentVideo.voteAverage) : '',
|
||||
mediaType: currentVideo?.mediaType || 'movie',
|
||||
seasonNumber: currentVideo?.seasonNumber ? String(currentVideo.seasonNumber) : '',
|
||||
seasonName: currentVideo?.seasonName || '',
|
||||
};
|
||||
|
||||
setManualData(newManualData);
|
||||
}
|
||||
}, [showManualInput, isOpen, currentVideo, currentTitle]);
|
||||
|
||||
const handleSearch = async () => {
|
||||
if (!searchQuery.trim()) {
|
||||
setError('请输入搜索关键词');
|
||||
@@ -224,6 +273,92 @@ export default function CorrectDialog({
|
||||
setSeasons([]);
|
||||
};
|
||||
|
||||
// 切换到手动输入模式
|
||||
const handleShowManualInput = () => {
|
||||
setShowManualInput(true);
|
||||
setShowSeasonSelection(false);
|
||||
setResults([]);
|
||||
};
|
||||
|
||||
// 返回搜索模式
|
||||
const handleBackToSearch = () => {
|
||||
setShowManualInput(false);
|
||||
};
|
||||
|
||||
// 处理手动提交
|
||||
const handleManualSubmit = async () => {
|
||||
// 验证必填字段
|
||||
if (!manualData.title.trim()) {
|
||||
setError('请输入影片标题');
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果提供了 TMDB ID,验证其格式
|
||||
if (manualData.tmdbId.trim() && isNaN(Number(manualData.tmdbId))) {
|
||||
setError('TMDB ID 必须是数字');
|
||||
return;
|
||||
}
|
||||
|
||||
if (manualData.voteAverage && (isNaN(Number(manualData.voteAverage)) || Number(manualData.voteAverage) < 0 || Number(manualData.voteAverage) > 10)) {
|
||||
setError('评分必须是 0-10 之间的数字');
|
||||
return;
|
||||
}
|
||||
|
||||
if (manualData.mediaType === 'tv' && manualData.seasonNumber && isNaN(Number(manualData.seasonNumber))) {
|
||||
setError('季数必须是数字');
|
||||
return;
|
||||
}
|
||||
|
||||
setCorrecting(true);
|
||||
setError('');
|
||||
|
||||
try {
|
||||
const body: any = {
|
||||
key: videoKey,
|
||||
title: manualData.title.trim(),
|
||||
posterPath: manualData.posterPath.trim() || null,
|
||||
releaseDate: manualData.releaseDate.trim() || '',
|
||||
overview: manualData.overview.trim() || '',
|
||||
voteAverage: manualData.voteAverage ? Number(manualData.voteAverage) : 0,
|
||||
mediaType: manualData.mediaType,
|
||||
};
|
||||
|
||||
// 添加 TMDB ID(如果提供)
|
||||
if (manualData.tmdbId.trim()) {
|
||||
body.tmdbId = Number(manualData.tmdbId);
|
||||
}
|
||||
|
||||
// 添加豆瓣 ID(如果提供)
|
||||
if (manualData.doubanId.trim()) {
|
||||
body.doubanId = manualData.doubanId.trim();
|
||||
}
|
||||
|
||||
// 如果是电视剧且有季度信息
|
||||
if (manualData.mediaType === 'tv' && manualData.seasonNumber) {
|
||||
body.seasonNumber = Number(manualData.seasonNumber);
|
||||
body.seasonName = manualData.seasonName.trim() || `第 ${manualData.seasonNumber} 季`;
|
||||
}
|
||||
|
||||
const response = await fetch('/api/openlist/correct', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('纠错失败');
|
||||
}
|
||||
|
||||
onCorrect();
|
||||
onClose();
|
||||
} catch (err) {
|
||||
console.error('纠错失败:', err);
|
||||
setError('纠错失败,请重试');
|
||||
} finally {
|
||||
setCorrecting(false);
|
||||
}
|
||||
};
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
||||
return createPortal(
|
||||
@@ -243,37 +378,230 @@ export default function CorrectDialog({
|
||||
</div>
|
||||
|
||||
{/* 搜索框 */}
|
||||
<div className='p-4 border-b border-gray-200 dark:border-gray-700'>
|
||||
<div className='flex gap-2'>
|
||||
<input
|
||||
type='text'
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
handleSearch();
|
||||
}
|
||||
}}
|
||||
placeholder='输入搜索关键词'
|
||||
className='flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent'
|
||||
/>
|
||||
<button
|
||||
onClick={handleSearch}
|
||||
disabled={searching}
|
||||
className='px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors disabled:bg-gray-400 disabled:cursor-not-allowed flex items-center gap-2'
|
||||
>
|
||||
<Search size={20} />
|
||||
<span className='hidden sm:inline'>{searching ? '搜索中...' : '搜索'}</span>
|
||||
</button>
|
||||
{!showManualInput && (
|
||||
<div className='p-4 border-b border-gray-200 dark:border-gray-700'>
|
||||
<div className='flex gap-2'>
|
||||
<input
|
||||
type='text'
|
||||
value={searchQuery}
|
||||
onChange={(e) => setSearchQuery(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
handleSearch();
|
||||
}
|
||||
}}
|
||||
placeholder='输入搜索关键词'
|
||||
className='flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent'
|
||||
/>
|
||||
<button
|
||||
onClick={handleSearch}
|
||||
disabled={searching}
|
||||
className='px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors disabled:bg-gray-400 disabled:cursor-not-allowed flex items-center gap-2'
|
||||
>
|
||||
<Search size={20} />
|
||||
<span className='hidden sm:inline'>{searching ? '搜索中...' : '搜索'}</span>
|
||||
</button>
|
||||
</div>
|
||||
{error && (
|
||||
<p className='mt-2 text-sm text-red-600 dark:text-red-400'>{error}</p>
|
||||
)}
|
||||
</div>
|
||||
{error && (
|
||||
<p className='mt-2 text-sm text-red-600 dark:text-red-400'>{error}</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 结果列表 */}
|
||||
<div className='flex-1 overflow-y-auto p-4'>
|
||||
{showSeasonSelection ? (
|
||||
{showManualInput ? (
|
||||
// 手动输入界面
|
||||
<div>
|
||||
<div className='mb-4 flex items-center gap-2'>
|
||||
<button
|
||||
onClick={handleBackToSearch}
|
||||
className='text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 flex items-center gap-1'
|
||||
>
|
||||
<span>←</span>
|
||||
<span>返回搜索</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className='space-y-4'>
|
||||
{/* 标题 - 必填 */}
|
||||
<div>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1'>
|
||||
影片标题 <span className='text-red-500'>*</span>
|
||||
</label>
|
||||
<input
|
||||
type='text'
|
||||
value={manualData.title}
|
||||
onChange={(e) => setManualData({ ...manualData, title: e.target.value })}
|
||||
placeholder='请输入影片标题'
|
||||
className='w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent'
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* TMDB ID - 可选 */}
|
||||
<div>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1'>
|
||||
TMDB ID(可选)
|
||||
</label>
|
||||
<input
|
||||
type='text'
|
||||
value={manualData.tmdbId}
|
||||
onChange={(e) => setManualData({ ...manualData, tmdbId: e.target.value })}
|
||||
placeholder='例如:550'
|
||||
className='w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent'
|
||||
/>
|
||||
<p className='mt-1 text-xs text-gray-500 dark:text-gray-400'>
|
||||
可在 TMDB 网站查找影片对应的 ID
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* 豆瓣 ID - 可选 */}
|
||||
<div>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1'>
|
||||
豆瓣 ID(可选)
|
||||
</label>
|
||||
<input
|
||||
type='text'
|
||||
value={manualData.doubanId}
|
||||
onChange={(e) => setManualData({ ...manualData, doubanId: e.target.value })}
|
||||
placeholder='例如:1292052'
|
||||
className='w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent'
|
||||
/>
|
||||
<p className='mt-1 text-xs text-gray-500 dark:text-gray-400'>
|
||||
可在豆瓣网站查找影片对应的 ID
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* 媒体类型 */}
|
||||
<div>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1'>
|
||||
类型
|
||||
</label>
|
||||
<div className='flex gap-4'>
|
||||
<label className='flex items-center'>
|
||||
<input
|
||||
type='radio'
|
||||
value='movie'
|
||||
checked={manualData.mediaType === 'movie'}
|
||||
onChange={(e) => setManualData({ ...manualData, mediaType: e.target.value as 'movie' | 'tv' })}
|
||||
className='mr-2'
|
||||
/>
|
||||
<span className='text-gray-900 dark:text-gray-100'>电影</span>
|
||||
</label>
|
||||
<label className='flex items-center'>
|
||||
<input
|
||||
type='radio'
|
||||
value='tv'
|
||||
checked={manualData.mediaType === 'tv'}
|
||||
onChange={(e) => setManualData({ ...manualData, mediaType: e.target.value as 'movie' | 'tv' })}
|
||||
className='mr-2'
|
||||
/>
|
||||
<span className='text-gray-900 dark:text-gray-100'>电视剧</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 如果是电视剧,显示季度信息 */}
|
||||
{manualData.mediaType === 'tv' && (
|
||||
<>
|
||||
<div>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1'>
|
||||
季数(可选)
|
||||
</label>
|
||||
<input
|
||||
type='text'
|
||||
value={manualData.seasonNumber}
|
||||
onChange={(e) => setManualData({ ...manualData, seasonNumber: e.target.value })}
|
||||
placeholder='例如:1'
|
||||
className='w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent'
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1'>
|
||||
季名称(可选)
|
||||
</label>
|
||||
<input
|
||||
type='text'
|
||||
value={manualData.seasonName}
|
||||
onChange={(e) => setManualData({ ...manualData, seasonName: e.target.value })}
|
||||
placeholder='例如:第 1 季'
|
||||
className='w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent'
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* 封面图链接 */}
|
||||
<div>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1'>
|
||||
封面图链接(可选)
|
||||
</label>
|
||||
<input
|
||||
type='text'
|
||||
value={manualData.posterPath}
|
||||
onChange={(e) => setManualData({ ...manualData, posterPath: e.target.value })}
|
||||
placeholder='请输入图片链接'
|
||||
className='w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent'
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 上映日期 */}
|
||||
<div>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1'>
|
||||
上映日期(可选)
|
||||
</label>
|
||||
<input
|
||||
type='date'
|
||||
value={manualData.releaseDate}
|
||||
onChange={(e) => setManualData({ ...manualData, releaseDate: e.target.value })}
|
||||
className='w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent'
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 评分 */}
|
||||
<div>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1'>
|
||||
评分(可选,0-10)
|
||||
</label>
|
||||
<input
|
||||
type='text'
|
||||
value={manualData.voteAverage}
|
||||
onChange={(e) => setManualData({ ...manualData, voteAverage: e.target.value })}
|
||||
placeholder='例如:8.5'
|
||||
className='w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent'
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 简介 */}
|
||||
<div>
|
||||
<label className='block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1'>
|
||||
简介(可选)
|
||||
</label>
|
||||
<textarea
|
||||
value={manualData.overview}
|
||||
onChange={(e) => setManualData({ ...manualData, overview: e.target.value })}
|
||||
placeholder='请输入影片简介'
|
||||
rows={3}
|
||||
className='w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-transparent'
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 错误提示 */}
|
||||
{error && (
|
||||
<p className='text-sm text-red-600 dark:text-red-400'>{error}</p>
|
||||
)}
|
||||
|
||||
{/* 提交按钮 */}
|
||||
<button
|
||||
onClick={handleManualSubmit}
|
||||
disabled={correcting}
|
||||
className='w-full px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors disabled:bg-gray-400 disabled:cursor-not-allowed'
|
||||
>
|
||||
{correcting ? '提交中...' : '提交纠错'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
) : showSeasonSelection ? (
|
||||
// 季度选择界面
|
||||
<div>
|
||||
<div className='mb-4 flex items-center gap-2'>
|
||||
@@ -360,64 +688,90 @@ export default function CorrectDialog({
|
||||
</div>
|
||||
) : results.length === 0 ? (
|
||||
// 空状态
|
||||
<div className='text-center py-12 text-gray-500 dark:text-gray-400'>
|
||||
{searching ? '搜索中...' : '请输入关键词搜索'}
|
||||
</div>
|
||||
<>
|
||||
<div className='text-center py-12 text-gray-500 dark:text-gray-400'>
|
||||
{searching ? '搜索中...' : '请输入关键词搜索'}
|
||||
</div>
|
||||
|
||||
{/* 手动纠错入口 */}
|
||||
{!searching && (
|
||||
<div className='mt-6 pt-4 border-t border-gray-200 dark:border-gray-700 text-center'>
|
||||
<button
|
||||
onClick={handleShowManualInput}
|
||||
className='text-xs text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors'
|
||||
>
|
||||
搜不到影片?手动纠错
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
// 搜索结果列表
|
||||
<div className='space-y-3'>
|
||||
{results.map((result) => (
|
||||
<div
|
||||
key={result.id}
|
||||
className='flex gap-3 p-3 border border-gray-200 dark:border-gray-700 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors'
|
||||
<>
|
||||
<div className='space-y-3'>
|
||||
{results.map((result) => (
|
||||
<div
|
||||
key={result.id}
|
||||
className='flex gap-3 p-3 border border-gray-200 dark:border-gray-700 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors'
|
||||
>
|
||||
{/* 海报 */}
|
||||
<div className='flex-shrink-0 w-16 h-24 relative rounded overflow-hidden bg-gray-200 dark:bg-gray-700'>
|
||||
{result.poster_path ? (
|
||||
<Image
|
||||
src={processImageUrl(getTMDBImageUrl(result.poster_path))}
|
||||
alt={result.title || result.name || ''}
|
||||
fill
|
||||
className='object-cover'
|
||||
referrerPolicy='no-referrer'
|
||||
/>
|
||||
) : (
|
||||
<div className='w-full h-full flex items-center justify-center text-gray-400 text-xs'>
|
||||
无海报
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 信息 */}
|
||||
<div className='flex-1 min-w-0'>
|
||||
<h3 className='font-semibold text-gray-900 dark:text-gray-100 truncate'>
|
||||
{result.title || result.name}
|
||||
</h3>
|
||||
<p className='text-sm text-gray-600 dark:text-gray-400 mt-1'>
|
||||
{result.media_type === 'movie' ? '电影' : '电视剧'} •{' '}
|
||||
{result.release_date?.split('-')[0] ||
|
||||
result.first_air_date?.split('-')[0] ||
|
||||
'未知'}{' '}
|
||||
• 评分: {result.vote_average.toFixed(1)}
|
||||
</p>
|
||||
<p className='text-xs text-gray-500 dark:text-gray-500 mt-1 line-clamp-2'>
|
||||
{result.overview || '暂无简介'}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* 选择按钮 */}
|
||||
<div className='flex-shrink-0 flex items-center'>
|
||||
<button
|
||||
onClick={() => handleSelectResult(result)}
|
||||
disabled={correcting || loadingSeasons}
|
||||
className='px-3 py-1.5 bg-green-600 hover:bg-green-700 text-white text-sm rounded-lg transition-colors disabled:bg-gray-400 disabled:cursor-not-allowed'
|
||||
>
|
||||
{correcting || loadingSeasons ? '处理中...' : '选择'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* 手动纠错入口 */}
|
||||
<div className='mt-6 pt-4 border-t border-gray-200 dark:border-gray-700 text-center'>
|
||||
<button
|
||||
onClick={handleShowManualInput}
|
||||
className='text-xs text-gray-500 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 transition-colors'
|
||||
>
|
||||
{/* 海报 */}
|
||||
<div className='flex-shrink-0 w-16 h-24 relative rounded overflow-hidden bg-gray-200 dark:bg-gray-700'>
|
||||
{result.poster_path ? (
|
||||
<Image
|
||||
src={processImageUrl(getTMDBImageUrl(result.poster_path))}
|
||||
alt={result.title || result.name || ''}
|
||||
fill
|
||||
className='object-cover'
|
||||
referrerPolicy='no-referrer'
|
||||
/>
|
||||
) : (
|
||||
<div className='w-full h-full flex items-center justify-center text-gray-400 text-xs'>
|
||||
无海报
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 信息 */}
|
||||
<div className='flex-1 min-w-0'>
|
||||
<h3 className='font-semibold text-gray-900 dark:text-gray-100 truncate'>
|
||||
{result.title || result.name}
|
||||
</h3>
|
||||
<p className='text-sm text-gray-600 dark:text-gray-400 mt-1'>
|
||||
{result.media_type === 'movie' ? '电影' : '电视剧'} •{' '}
|
||||
{result.release_date?.split('-')[0] ||
|
||||
result.first_air_date?.split('-')[0] ||
|
||||
'未知'}{' '}
|
||||
• 评分: {result.vote_average.toFixed(1)}
|
||||
</p>
|
||||
<p className='text-xs text-gray-500 dark:text-gray-500 mt-1 line-clamp-2'>
|
||||
{result.overview || '暂无简介'}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* 选择按钮 */}
|
||||
<div className='flex-shrink-0 flex items-center'>
|
||||
<button
|
||||
onClick={() => handleSelectResult(result)}
|
||||
disabled={correcting || loadingSeasons}
|
||||
className='px-3 py-1.5 bg-green-600 hover:bg-green-700 text-white text-sm rounded-lg transition-colors disabled:bg-gray-400 disabled:cursor-not-allowed'
|
||||
>
|
||||
{correcting || loadingSeasons ? '处理中...' : '选择'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
搜不到影片?手动纠错
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -216,5 +216,11 @@ export function getTMDBImageUrl(
|
||||
size: string = 'w500'
|
||||
): string {
|
||||
if (!path) return '';
|
||||
|
||||
// 如果已经是完整的 URL (http:// 或 https://),直接返回
|
||||
if (path.startsWith('http://') || path.startsWith('https://')) {
|
||||
return path;
|
||||
}
|
||||
|
||||
return `https://image.tmdb.org/t/p/${size}${path}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user