"use client" import { useState } from "react" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { Badge } from "@/components/ui/badge" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Switch } from "@/components/ui/switch" import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" import { Webhook, Plus, Settings, Trash2, Play, Pause, CheckCircle2, XCircle, Clock, RefreshCw, Eye } from "lucide-react" const subscriptions = [ { id: "1", name: "用户标签变更通知", type: "webhook", endpoint: "https://api.example.com/webhook/tags", event: "tag_changed", status: "active", lastTriggered: "2024-01-15 14:20:00", successRate: 99.5, }, { id: "2", name: "高价值用户预警", type: "webhook", endpoint: "https://api.example.com/webhook/alerts", event: "high_value_alert", status: "active", lastTriggered: "2024-01-15 10:15:00", successRate: 98.2, }, { id: "3", name: "数据同步完成通知", type: "email", endpoint: "admin@example.com", event: "sync_completed", status: "paused", lastTriggered: "2024-01-14 23:00:00", successRate: 100, }, ] export default function SubscriptionPage() { const [showCreateDialog, setShowCreateDialog] = useState(false) const getStatusBadge = (status: string) => { switch (status) { case "active": return 运行中 case "paused": return 已暂停 case "error": return 异常 default: return 未知 } } return (
{/* 页面标题 */}

数据订阅

配置数据变更的实时推送和通知

{/* 统计卡片 */}

订阅总数

8

今日推送

1,256

成功率

99.2%

活跃订阅

6

{/* 订阅列表 */} 订阅列表 管理所有数据订阅配置 订阅名称 类型 目标地址 触发事件 状态 成功率 操作 {subscriptions.map((sub) => ( {sub.name} {sub.type === "webhook" ? "Webhook" : "邮件"} {sub.endpoint} {sub.event} {getStatusBadge(sub.status)} {sub.successRate}%
))}
{/* 创建订阅弹窗 */} 创建数据订阅 配置数据变更的实时推送

创建后立即开始推送

) }