import { Lock, Trash2, Unlock } from "lucide-react" import { useState } from "react" import DataTable from "@/components/data-table" import Page from "@/components/page" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import type { WhiteIpItem } from "@/lib/models/whitelist" // TODO: 后端白名单接口就绪后,将 saveWhiteIp/fetchWhiteList 接入(见 src/api/whitelist.ts) export default function WhitelistPage() { const [ip, setIp] = useState("") const [list, setList] = useState([]) const handleSave = () => { const value = ip.trim() if (!value) return // TODO: await saveWhiteIp(value) setList(prev => [ { id: Date.now(), ip: value, createTime: "", isLocked: "未锁定" }, ...prev, ]) setIp("") } return (
setIp(e.target.value)} onKeyDown={e => e.key === "Enter" && handleSave()} placeholder="请输入IP地址并点击保存白名单" className="max-w-sm" />

当前白名单列表

当前仅允许保留白名单数量:5个
data={list} status="done" columns={[ { accessorKey: "ip", header: "IP地址", }, { accessorKey: "createTime", header: "设置时间", }, { accessorKey: "isLocked", header: "锁定状态", cell: ({ row }) => { const isLocked = row.original.isLocked === "已锁定" return ( {row.original.isLocked} ) }, }, { id: "actions", header: "操作", cell: ({ row }) => { const item = row.original // TODO: 接入 lockWhiteIp / deleteWhiteIp return (
) }, }, ]} />
) }