import { useState } from 'react'; import { SourceManager } from '@/components/settings/SourceManager'; import type { VideoSource } from '@/lib/types'; import { PREMIUM_SOURCES } from '@/lib/api/premium-sources'; interface PremiumSourceSettingsProps { sources: VideoSource[]; onSourcesChange: (sources: VideoSource[]) => void; onRestoreDefaults: () => void; onAddSource: () => void; onEditSource?: (source: VideoSource) => void; } export function PremiumSourceSettings({ sources, onSourcesChange, onRestoreDefaults, onAddSource, onEditSource, }: PremiumSourceSettingsProps) { const [showAllSources, setShowAllSources] = useState(false); const [searchQuery, setSearchQuery] = useState(''); const filteredSources = sources.filter(source => source.name.toLowerCase().includes(searchQuery.toLowerCase()) || source.baseUrl.toLowerCase().includes(searchQuery.toLowerCase()) ); const displayedSources = showAllSources || searchQuery ? filteredSources : filteredSources.slice(0, 10); const handleToggle = (id: string) => { const updated = sources.map(s => s.id === id ? { ...s, enabled: !s.enabled } : s ); onSourcesChange(updated); }; const handleDelete = (id: string) => { const updated = sources.filter(s => s.id !== id); onSourcesChange(updated); }; const handleReorder = (id: string, direction: 'up' | 'down') => { const currentIndex = sources.findIndex(s => s.id === id); if (currentIndex === -1) return; const newIndex = direction === 'up' ? currentIndex - 1 : currentIndex + 1; if (newIndex < 0 || newIndex >= sources.length) return; const updated = [...sources]; [updated[currentIndex], updated[newIndex]] = [updated[newIndex], updated[currentIndex]]; // Update priorities updated.forEach((s, idx) => s.priority = idx + 1); onSourcesChange(updated); }; return (
管理高级内容来源,调整优先级和启用状态
{/* Search Bar */}