'use client'; import { useEffect, useState } from 'react'; interface SearchLoadingAnimationProps { currentSource?: string; checkedSources?: number; totalSources?: number; checkedVideos?: number; totalVideos?: number; stage?: 'searching' | 'checking'; } export function SearchLoadingAnimation({ currentSource, checkedSources = 0, totalSources = 16, checkedVideos = 0, totalVideos = 0, stage = 'searching' }: SearchLoadingAnimationProps) { const [dots, setDots] = useState(''); useEffect(() => { const dotInterval = setInterval(() => { setDots((prev) => (prev.length >= 3 ? '' : prev + '.')); }, 500); return () => clearInterval(dotInterval); }, []); // Calculate unified progress (0-100%) // Stage 1: Search sources (0-60%) // Stage 2: Check videos (60-100%) let progress = 0; let statusText = ''; if (stage === 'searching') { progress = totalSources > 0 ? (checkedSources / totalSources) * 60 : 0; statusText = `${checkedSources}/${totalSources} 个源`; } else if (stage === 'checking') { progress = 60 + (totalVideos > 0 ? (checkedVideos / totalVideos) * 40 : 0); statusText = `${checkedVideos}/${totalVideos} 个视频`; } return (
{/* Loading Message with Icon */}
{/* Spinning Icon */} {stage === 'searching' ? '正在搜索视频源' : '正在检测视频可用性'}{dots}
{/* Progress Bar - Unified 0-100% */}
{/* Shimmer Effect */}
{/* Progress Info - Real-time count */}
{statusText} {Math.round(progress)}%
); }