'use client';
/**
* IPTVSourceManager - Admin UI to manage M3U playlist sources
*/
import { useState } from 'react';
import { useIPTVStore, type IPTVSource } from '@/lib/store/iptv-store';
import { Icons } from '@/components/ui/Icon';
export function IPTVSourceManager() {
const { sources, addSource, removeSource, refreshSources, isLoading } = useIPTVStore();
const [name, setName] = useState('');
const [url, setUrl] = useState('');
const [showAdd, setShowAdd] = useState(false);
const handleAdd = () => {
if (!name.trim() || !url.trim()) return;
addSource(name.trim(), url.trim());
setName('');
setUrl('');
setShowAdd(false);
// Auto-refresh after adding
setTimeout(() => refreshSources(), 100);
};
return (
直播源管理
{/* Add Source Form */}
{showAdd && (
)}
{/* Source List */}
{sources.length === 0 ? (
暂无直播源,请添加 M3U 播放列表链接
) : (
{sources.map((source) => (
{source.name}
{source.url}
))}
)}
);
}