import { useState } from 'react'; import { Send, Bell, MessageSquare, Navigation, Mail, Check, ToggleLeft, ToggleRight, Webhook, Settings, TestTube } from 'lucide-react'; import { Card, CardContent } from '@/components/ui/card'; import { notificationChannels } from '@/lib/mock'; const iconMap: Record = { Send, Bell, MessageSquare, Navigation, Mail, }; const channelStyle: Record = { feishu: { bg: 'bg-[rgba(0,150,255,0.15)]', color: 'text-[#00a8ff]' }, dingtalk: { bg: 'bg-[rgba(0,160,255,0.15)]', color: 'text-[#0089ff]' }, wechat: { bg: 'bg-[rgba(7,193,96,0.15)]', color: 'text-[#07c160]' }, telegram: { bg: 'bg-[rgba(0,136,204,0.15)]', color: 'text-[#0088cc]' }, email: { bg: 'bg-[rgba(220,50,32,0.15)]', color: 'text-[#ef5350]' }, }; const allEvents = [ { key: 'ticket_created', label: '工单创建' }, { key: 'ticket_approved', label: '审批通过' }, { key: 'ticket_rejected', label: '审批拒绝' }, { key: 'ticket_executed', label: '执行完成' }, { key: 'ticket_failed', label: '执行失败' }, { key: 'ticket_rollback', label: '工单回滚' }, ]; export default function NotificationsPage() { const [channels, setChannels] = useState(notificationChannels); const [editChannel, setEditChannel] = useState(null); const toggleChannel = (id: number) => { setChannels(prev => prev.map(c => c.id === id ? { ...c, enabled: !c.enabled } : c)); }; return (

通知渠道配置

配置多渠道通知,支持飞书、钉钉、企业微信、Telegram

{[ { label: '渠道总数', value: channels.length, icon: Webhook, color: 'text-blue-400', bg: 'bg-blue-400/10' }, { label: '已启用', value: channels.filter(c => c.enabled).length, icon: Check, color: 'text-green-400', bg: 'bg-green-400/10' }, { label: '未启用', value: channels.filter(c => !c.enabled).length, icon: Bell, color: 'text-gray-400', bg: 'bg-gray-400/10' }, ].map((s, i) => (
{s.value}
{s.label}
))}
{channels.map(channel => { const Icon = iconMap[channel.icon] || Bell; const style = channelStyle[channel.type] || channelStyle.email; return (
setEditChannel(channel)} >
{channel.name}
{channel.description}
{channel.enabled && channel.events && (
{channel.events.slice(0, 3).map(e => ( {allEvents.find(a => a.key === e)?.label || e} ))} {channel.events.length > 3 && +{channel.events.length - 3}}
)}
{channel.enabled ? '已启用' : '未启用'}
); })}
{/* 编辑弹窗 */} {editChannel && (
setEditChannel(null)}>
e.stopPropagation()}>

配置 {editChannel.name}

{allEvents.map(evt => ( ))}
)}
); }