import { useState } from 'react' import { useNavigate } from 'react-router-dom' import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' import { motion } from 'framer-motion' import { Plus, Copy, Trash2, ArrowLeft, ToggleLeft, ToggleRight, Loader2, Check, AlertCircle, } from 'lucide-react' import { api } from '@/lib/api' import { toast } from '@/components/Toast' import { Logo } from '@/components/Logo' const BRAND = '#8B5CF6' function formatTime(ts: number) { const d = new Date(ts * 1000) return d.toLocaleString('zh-CN') } export function AdminUuids() { const navigate = useNavigate() const qc = useQueryClient() const [label, setLabel] = useState('') const [copied, setCopied] = useState(null) const { data: records = [], isLoading } = useQuery({ queryKey: ['admin-uuids'], queryFn: () => api.listUuids(), }) const create = useMutation({ mutationFn: () => api.createUuid(label), onSuccess: () => { qc.invalidateQueries({ queryKey: ['admin-uuids'] }) setLabel('') toast('已创建新 UUID', 'success') }, onError: (err: any) => toast(err?.message || '创建失败', 'error'), }) const toggle = useMutation({ mutationFn: ({ uuid, enabled }: { uuid: string; enabled: boolean }) => api.toggleUuid(uuid, enabled), onSuccess: () => qc.invalidateQueries({ queryKey: ['admin-uuids'] }), onError: (err: any) => toast(err?.message || '操作失败', 'error'), }) const remove = useMutation({ mutationFn: (uuid: string) => api.deleteUuid(uuid), onSuccess: () => { qc.invalidateQueries({ queryKey: ['admin-uuids'] }) toast('已删除', 'success') }, onError: (err: any) => toast(err?.message || '删除失败', 'error'), }) const handleCopy = async (uuid: string) => { try { await navigator.clipboard.writeText(uuid) setCopied(uuid) setTimeout(() => setCopied(null), 1500) } catch { toast('复制失败', 'error') } } return (
{/* 背景光晕 */}
{/* 顶栏 */}
Stock Panel
{/* 内容 */}

访问 UUID 管理

为合伙人创建、分发和管理访问 UUID。

{/* 创建区 */}
setLabel(e.target.value)} className="flex-1 px-3 py-2 rounded-input bg-base border border-border text-sm focus:outline-none focus:border-accent focus:ring-1 focus:ring-accent/30 transition-all" />
{/* 列表 */}
{isLoading ? (
) : records.length === 0 ? (
暂无 UUID,点击上方按钮创建第一个。
) : ( {records.map((r) => ( ))}
UUID 备注 创建时间 状态 操作
{r.uuid}
{r.label || '—'} {formatTime(r.created_at)}
)}
提示:禁用 UUID 后,持有该 UUID 的合伙人将无法继续访问,但不会删除记录。
) }