"use client" import { useState } from "react" import { Card } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import { Checkbox } from "@/components/ui/checkbox" import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { Battery, Smartphone, MessageCircle, Users, Clock } from "lucide-react" import { ImeiDisplay } from "@/components/ImeiDisplay" export interface Device { id: string imei: string name: string status: "online" | "offline" battery: number wechatId: string friendCount: number todayAdded: number messageCount: number lastActive: string addFriendStatus: "normal" | "abnormal" } interface DeviceGridProps { devices: Device[] selectable?: boolean selectedDevices?: string[] onSelect?: (deviceIds: string[]) => void itemsPerRow?: number } export function DeviceGrid({ devices, selectable = false, selectedDevices = [], onSelect, itemsPerRow = 2, }: DeviceGridProps) { const [selectedDevice, setSelectedDevice] = useState(null) const handleSelectAll = () => { if (selectedDevices.length === devices.length) { onSelect?.([]) } else { onSelect?.(devices.map((d) => d.id)) } } return (
{selectable && (
0} onCheckedChange={handleSelectAll} /> 全选
已选择 {selectedDevices.length} 个设备
)}
{devices.map((device) => ( { if (selectable) { const newSelection = selectedDevices.includes(device.id) ? selectedDevices.filter((id) => id !== device.id) : [...selectedDevices, device.id] onSelect?.(newSelection) } else { setSelectedDevice(device) } }} >
{selectable && ( e.stopPropagation()} /> )}
{device.name}
{device.status === "online" ? "在线" : "离线"}
{device.battery}%
{device.friendCount}
{device.messageCount}
+{device.todayAdded}
IMEI: {device.imei}
微信号: {device.wechatId}
{device.addFriendStatus === "normal" ? "加友正常" : "加友异常"}
))}
setSelectedDevice(null)}> 设备详情 {selectedDevice && (

{selectedDevice.name}

IMEI:

{selectedDevice.status === "online" ? "在线" : "离线"}
电池电量
{selectedDevice.battery}%
好友数量
{selectedDevice.friendCount}
今日新增
+{selectedDevice.todayAdded}
消息数量
{selectedDevice.messageCount}
微信账号
{selectedDevice.wechatId}
最后活跃
{selectedDevice.lastActive}
加友状态
{selectedDevice.addFriendStatus === "normal" ? "加友正常" : "加友异常"}
)}
) }