'use client'; import { LucideIcon, Monitor, X } from 'lucide-react'; import { createPortal } from 'react-dom'; interface DeviceItem { tokenId: string; deviceInfo: string; isCurrent: boolean; createdAt: string; lastUsed: string; } interface DeviceManagementPanelProps { isOpen: boolean; mounted: boolean; onClose: () => void; devices: DeviceItem[]; devicesLoading: boolean; revoking: string | null; onRevokeDevice: (tokenId: string) => void; onRevokeAllDevices: () => void; getDeviceIcon: (deviceInfo: string) => LucideIcon; } export function DeviceManagementPanel({ isOpen, mounted, onClose, devices, devicesLoading, revoking, onRevokeDevice, onRevokeAllDevices, getDeviceIcon, }: DeviceManagementPanelProps) { if (!isOpen || !mounted) return null; return createPortal( <>
e.preventDefault()} onWheel={(e) => e.preventDefault()} style={{ touchAction: 'none' }} />
e.stopPropagation()} style={{ touchAction: 'auto' }} >

设备管理

{devicesLoading ? (
{[1, 2, 3].map((i) => (
))}
加载中...
) : devices.length === 0 ? (

暂无登录设备

) : (
{devices .slice() .sort((a, b) => { if (a.isCurrent && !b.isCurrent) return -1; if (!a.isCurrent && b.isCurrent) return 1; return 0; }) .map((device) => { const DeviceIcon = getDeviceIcon(device.deviceInfo); return (
{device.deviceInfo} {device.isCurrent && ( 当前设备 )}
登录时间: {new Date(device.createdAt).toLocaleString('zh-CN')}
最后活跃: {new Date(device.lastUsed).toLocaleString('zh-CN')}
{!device.isCurrent && ( )}
); })}
)}

登出所有设备后需要重新登录

, document.body ); }