"use client" import { useState } from "react" import { Card } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Checkbox } from "@/components/ui/checkbox" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" import { Search, Plus } from "lucide-react" interface Device { id: string name: string account: string status: "online" | "offline" } const mockDevices: Device[] = [ { id: "1", name: "iPhone 13 Pro", account: "wxid_abc123", status: "online", }, { id: "2", name: "Huawei P40", account: "wxid_xyz789", status: "offline", }, ] interface DeviceSelectorProps { selectedDevices: string[] onChange: (devices: string[]) => void } export function DeviceSelector({ selectedDevices, onChange }: DeviceSelectorProps) { const [searchQuery, setSearchQuery] = useState("") const toggleSelectAll = () => { if (selectedDevices.length === mockDevices.length) { onChange([]) } else { onChange(mockDevices.map((device) => device.id)) } } const toggleDevice = (deviceId: string) => { if (selectedDevices.includes(deviceId)) { onChange(selectedDevices.filter((id) => id !== deviceId)) } else { onChange([...selectedDevices, deviceId]) } } return (
setSearchQuery(e.target.value)} className="pl-9" />
设备名称 微信账号 状态 {mockDevices.map((device) => ( toggleDevice(device.id)} /> {device.name} {device.account} {device.status === "online" ? "在线" : "离线"} ))}
) }