import { useState } from 'react'; import { SourceManager } from '@/components/settings/SourceManager'; import type { VideoSource } from '@/lib/types'; import { DEFAULT_SOURCES } from '@/lib/api/default-sources'; interface SourceSettingsProps { sources: VideoSource[]; onSourcesChange: (sources: VideoSource[]) => void; onRestoreDefaults: () => void; onAddSource: () => void; onEditSource?: (source: VideoSource) => void; } export function SourceSettings({ sources, onSourcesChange, onRestoreDefaults, onAddSource, onEditSource, }: SourceSettingsProps) { 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 */}
setSearchQuery(e.target.value)} className="w-full px-4 py-2 pl-10 rounded-[var(--radius-2xl)] bg-[var(--glass-bg)] border border-[var(--glass-border)] text-[var(--text-color)] placeholder-[var(--text-color-secondary)] focus:outline-none focus:ring-2 focus:ring-[var(--accent-color)] transition-all duration-200" />
s.id)} /> {!searchQuery && sources.length > 10 && ( )}
); }