refactor: remove verbose logging, refine search animation, and update icon import.

This commit is contained in:
kuekhaoyang
2025-12-01 09:46:35 +08:00
parent b12c09b578
commit 20999e1159
14 changed files with 22 additions and 51 deletions
+10 -10
View File
@@ -10,9 +10,9 @@ interface SearchLoadingAnimationProps {
onComplete?: (checkedSources: number, totalSources: number) => void;
}
export function SearchLoadingAnimation({
currentSource,
checkedSources = 0,
export function SearchLoadingAnimation({
currentSource,
checkedSources = 0,
totalSources = 16,
isPaused = false,
onComplete,
@@ -54,7 +54,7 @@ export function SearchLoadingAnimation({
// Small delay to allow animation to settle
const timeout = setTimeout(() => {
onComplete(checkedSources, totalSources);
}, 300);
}, 100);
return () => clearTimeout(timeout);
}
}, [isComplete, onComplete, checkedSources, totalSources]);
@@ -78,7 +78,7 @@ export function SearchLoadingAnimation({
strokeLinecap="round"
/>
</svg>
<span className="text-sm font-medium text-[var(--text-color-secondary)]">
{dots}
</span>
@@ -86,19 +86,19 @@ export function SearchLoadingAnimation({
{/* Progress Bar - Unified 0-100% */}
<div className="w-full">
<div
<div
className="h-1 bg-[color-mix(in_srgb,var(--glass-bg)_50%,transparent)] overflow-hidden rounded-[var(--radius-full)]"
>
<div
className="h-full bg-[var(--accent-color)] transition-all duration-500 ease-out relative rounded-[var(--radius-full)]"
style={{
style={{
width: `${progress}%`
}}
>
{/* Shimmer Effect - Optimized for GPU with contain for better performance */}
<div
<div
className="absolute inset-0 animate-shimmer"
style={{
style={{
background: 'linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.3) 50%, transparent 100%)',
willChange: 'transform',
transform: 'translateZ(0)',
@@ -107,7 +107,7 @@ export function SearchLoadingAnimation({
></div>
</div>
</div>
{/* Progress Info - Real-time count with pause indicator */}
<div className="flex items-center justify-between mt-2 text-xs text-[var(--text-color-secondary)]">
<span className="flex items-center gap-2">
+5 -6
View File
@@ -8,12 +8,11 @@ export function ServiceWorkerRegister() {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js').then(
(registration) => {
console.log('ServiceWorker registration successful with scope: ', registration.scope);
},
(err) => {
console.log('ServiceWorker registration failed: ', err);
}
);
// Registration successful
})
.catch((err) => {
// Registration failed
});
});
}
}, []);
+1 -2
View File
@@ -4,6 +4,7 @@ import Link from 'next/link';
import Image from 'next/image';
import React from 'react';
import { Card } from '@/components/ui/Card';
import { Icons } from '@/components/ui/Icon';
interface AdultVideo {
vod_id: string | number;
@@ -133,8 +134,6 @@ function AdultGridNoMore() {
}
function AdultGridEmpty() {
// Using require to avoid top-level import issues if any, matching MovieGrid pattern
const { Icons } = require('@/components/ui/Icon');
return (
<div className="text-center py-20">
<Icons.Film size={64} className="text-[var(--text-color-secondary)] mx-auto mb-4" />
+1 -1
View File
@@ -4,6 +4,7 @@
*/
import { MovieCard } from './MovieCard';
import { Icons } from '@/components/ui/Icon';
interface DoubanMovie {
id: string;
@@ -81,7 +82,6 @@ function MovieGridNoMore() {
}
function MovieGridEmpty() {
const { Icons } = require('@/components/ui/Icon');
return (
<div className="text-center py-20">
<Icons.Film size={64} className="text-[var(--text-color-secondary)] mx-auto mb-4" />
+1 -1
View File
@@ -50,7 +50,7 @@ export function VideoMetadata({ videoData, source, title }: VideoMetadataProps)
)}
</div>
{videoData?.vod_content && (
<p className="text-sm sm:text-base text-[var(--text-secondary)] line-clamp-3">
<p className="text-sm sm:text-base text-[var(--text-secondary)]">
{videoData.vod_content.replace(/<[^>]*>/g, '')}
</p>
)}
-1
View File
@@ -77,7 +77,6 @@ export function VideoPlayer({ playUrl, videoId, currentEpisode, onBack }: VideoP
// Auto-retry with proxy if not already using it
if (!useProxy) {
console.log('Attempting to retry with proxy...');
setUseProxy(true);
setShouldAutoPlay(true); // Force autoplay after proxy retry
setVideoError('');
+1 -2
View File
@@ -27,12 +27,11 @@ export function useHLSPreloader({ src, currentTime, videoRef, isLoading }: UseHL
const fetchManifest = async () => {
try {
console.log('[Preloader] Fetching manifest:', src);
// Fetch manifest
const segments = await parseHLSManifest(src);
segmentsRef.current = segments;
setIsManifestLoaded(true);
const totalDuration = segments[segments.length - 1]?.startTime + segments[segments.length - 1]?.duration || 0;
console.log(`[Preloader] Parsed ${segments.length} segments. Total duration: ${totalDuration.toFixed(2)}s`);
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
if (errorMessage.includes('503') || errorMessage.includes('Network unavailable')) {
-4
View File
@@ -42,7 +42,6 @@ export function useHlsPlayer({
// EXCEPT for Chrome on Desktop which reports canPlayType as '' (false).
if (!isNativeHlsSupported) {
console.log('[HLS] Initializing hls.js');
hls = new Hls({
enableWorker: true,
lowLatencyMode: true,
@@ -53,7 +52,6 @@ export function useHlsPlayer({
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, () => {
console.log('[HLS] Manifest parsed');
// Check for HEVC/H.265 codec (limited browser support)
if (hls) {
@@ -115,13 +113,11 @@ export function useHlsPlayer({
}
});
} else {
console.log('[HLS] Using native HLS support');
// Native HLS support
video.src = src;
}
} else if (isNativeHlsSupported) {
// Fallback for environments where Hls.js is not supported but native is (e.g. iOS without MSE?)
console.log('[HLS] Using native HLS support (Hls.js not supported)');
video.src = src;
} else {
console.error('[HLS] HLS not supported in this browser');
+2 -4
View File
@@ -32,7 +32,7 @@ function useHistoryDownloader() {
// Skip if not m3u8
if (!url.endsWith('.m3u8')) continue;
console.log(`[HistoryDownloader] Queueing background download for: ${item.title}`);
// Queue background download
processedUrlsRef.current.add(url);
try {
@@ -46,9 +46,7 @@ function useHistoryDownloader() {
signal: controller.signal,
videoUrl: url, // Track metadata for this video
onProgress: (current, total) => {
if (current % 50 === 0) {
console.log(`[HistoryDownloader] ${item.title}: ${current}/${total}`);
}
// console.log removed as per instruction
}
});
} catch (error) {
-7
View File
@@ -17,7 +17,6 @@ class CacheManager {
try {
const stored = localStorage.getItem(METADATA_STORE);
if (stored) this.metadata = new Map(Object.entries(JSON.parse(stored)));
console.log('[CacheManager] Initialized with', this.metadata.size, 'entries');
} catch (error) { console.error('[CacheManager] Init failed:', error); }
this.initialized = true;
}
@@ -38,7 +37,6 @@ class CacheManager {
const meta = this.metadata.get(url);
if (!meta) return false;
if (Date.now() - meta.cachedAt > CACHE_TTL) {
console.log('[CacheManager] Cache expired:', url);
return false;
}
meta.lastAccessed = Date.now();
@@ -61,7 +59,6 @@ class CacheManager {
await this.initialize();
const stats = await this.getCacheStats();
if (stats.totalSizeMB > MAX_CACHE_SIZE_MB) {
console.log(`[CacheManager] Size ${stats.totalSizeMB.toFixed(2)}MB exceeds ${MAX_CACHE_SIZE_MB}MB`);
await this.cleanupOldEntries();
}
await this.cleanupExpiredEntries();
@@ -82,7 +79,6 @@ class CacheManager {
}
if (cleaned > 0) {
this.save();
console.log(`[CacheManager] Cleaned ${cleaned} expired entries`);
}
return cleaned;
}
@@ -101,7 +97,6 @@ class CacheManager {
}
if (removed > 0) {
this.save();
console.log(`[CacheManager] Removed ${removed} old entries`);
}
return removed;
}
@@ -120,7 +115,6 @@ class CacheManager {
}
if (cleared > 0) {
this.save();
console.log(`[CacheManager] Cleared ${cleared} entries for:`, videoUrl);
}
return cleared;
}
@@ -133,7 +127,6 @@ class CacheManager {
const count = this.metadata.size;
this.metadata.clear();
this.save();
console.log(`[CacheManager] Cleared all ${count} entries`);
return count;
}
}
-1
View File
@@ -61,7 +61,6 @@ export async function fetchWithRetry({ url, request, headers = {} }: FetchWithRe
clearTimeout(timeoutId);
if (response.ok) {
console.log(`✓ Proxy success on attempt ${attempt}: ${url.substring(0, 100)}...`);
break;
}
+1 -4
View File
@@ -60,12 +60,9 @@ export function preloadSegments({
return;
}
// Only log on significant seeks or initial start
// Mark as initialized or handle seek
if (!isInitializedRef.current) {
console.log(`[Preloader] Initial start at segment ${startIndex} (${currentTime.toFixed(2)}s)`);
isInitializedRef.current = true;
} else if (!isSequential) {
console.log(`[Preloader] Seek detected. Current Time: ${currentTime.toFixed(2)}s. Starting from segment ${startIndex}.`);
}
lastStartIndexRef.current = startIndex;
-7
View File
@@ -35,7 +35,6 @@ export async function parseHLSManifest(src: string): Promise<Segment[]> {
// Check if this is a master playlist
if (manifestText.includes('#EXT-X-STREAM-INF')) {
console.log('[HLS Parser] Master playlist detected, selecting variant...');
return parseMasterPlaylist(manifestText, src);
}
@@ -61,7 +60,6 @@ async function parseMasterPlaylist(content: string, baseUrl: string): Promise<Se
const line = lines[j].trim();
if (line && !line.startsWith('#')) {
const variantUrl = new URL(line, baseUrl).toString();
console.log(`[HLS Parser] Selected variant: ${variantUrl.substring(0, 100)}...`);
// Recursively parse the variant playlist
return parseHLSManifest(variantUrl);
}
@@ -86,7 +84,6 @@ function parseMediaPlaylist(content: string, baseUrl: string): Segment[] {
// Check for encryption
if (trimmed.startsWith('#EXT-X-KEY:')) {
isEncrypted = true;
console.log('[HLS Parser] Encrypted stream detected');
}
if (trimmed.startsWith('#EXTINF:')) {
@@ -105,9 +102,5 @@ function parseMediaPlaylist(content: string, baseUrl: string): Segment[] {
}
}
if (isEncrypted) {
console.log(`[HLS Parser] Parsed ${segments.length} encrypted segments`);
}
return segments;
}
-1
View File
@@ -50,7 +50,6 @@ export async function downloadSegmentQueue(options: DownloadQueueOptions): Promi
await cache.delete(url);
}
console.log(`[Preloader] 正在下载片段 ${currentIndex}/${segments.length}`);
const response = await fetch(url, { signal: fetchSignal });
if (response.ok) {