import { useMemo } from 'react' import { Check, AlertTriangle, X } from 'lucide-react' import { parseMultipleUrls, type ParsedId } from '@/lib/urlParser' interface ParsedIdListProps { value: string platform: string type: 'detail' | 'creator' onRemove?: (index: number) => void disabled?: boolean } export function ParsedIdList({ value, platform, type, onRemove, disabled }: ParsedIdListProps) { const parsed = useMemo(() => { return parseMultipleUrls(value, platform) }, [value, platform]) if (parsed.length === 0) return null const handleRemove = (index: number) => { if (disabled || !onRemove) return const items = value .split(/[,\n]+/) .map(s => s.trim()) .filter(Boolean) items.splice(index, 1) onRemove(index) } return (
已识别 {parsed.length} 个{type === 'detail' ? '帖子/视频' : '创作者'}:
{parsed.map((item, index) => ( handleRemove(index) : undefined} /> ))}
) } interface ParsedIdTagProps { item: ParsedId expectedType: 'detail' | 'creator' onRemove?: () => void } function ParsedIdTag({ item, expectedType, onRemove }: ParsedIdTagProps) { // 检查类型是否匹配 const typeMatch = item.type === 'unknown' || (expectedType === 'detail' && item.type === 'video') || (expectedType === 'creator' && item.type === 'creator') // 警告状态:小红书需要xsec_token const needsWarning = !item.isValid || !typeMatch return ( {needsWarning ? ( ) : ( )} {item.id.length > 20 ? item.id.slice(0, 8) + '...' + item.id.slice(-8) : item.id} {onRemove && ( )} ) }