'use client'; import { Download, Eye, MoreHorizontal, Pencil, Play, Trash2, } from 'lucide-react'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/components/ui/table'; import type { WAFIPGroup } from '@/lib/services/openflare'; import { formatDateTime } from '@/lib/utils'; import { ipGroupTypeLabels } from './helpers'; interface IPGroupsTableProps { groups: WAFIPGroup[]; syncingId: number | null; onView: (group: WAFIPGroup) => void; onEdit: (group: WAFIPGroup) => void; onDelete: (group: WAFIPGroup) => void; onSync: (group: WAFIPGroup) => void; onTest: (group: WAFIPGroup) => void; } export function IPGroupsTable({ groups, syncingId, onView, onEdit, onDelete, onSync, onTest, }: IPGroupsTableProps) { return ( 名称 类型 状态 IP 数 引用次数 同步状态 更新时间 操作 {groups.map((group) => ( {group.name} {ipGroupTypeLabels[group.type]} {group.enabled ? '启用' : '停用'} {group.ip_list.length} {group.referenced_by_rule_count} {group.last_sync_status ? `${group.last_sync_status}: ${group.last_sync_message}` : '尚无同步记录'} {group.updated_at ? formatDateTime(group.updated_at) : '—'} onView(group)}> 查看 onEdit(group)}> 编辑 {group.type === 'automatic' ? ( onTest(group)}> 测试规则 ) : null} {group.type === 'subscription' || group.type === 'automatic' ? ( onSync(group)} > {syncingId === group.id ? '同步中...' : group.type === 'automatic' ? '立即执行' : '立即同步'} ) : null} onDelete(group)} > 删除 ))}
); }