import React, { useState, useEffect } from 'react'; import { Layout, Menu, Typography } from 'antd'; import { AlertOutlined, ClockCircleOutlined, FileTextOutlined, BarChartOutlined, SettingOutlined, BellOutlined } from '@ant-design/icons'; import { getMenuList } from '../api/mune'; import AlarmOverview from '../components/alerts/AlarmOverview'; import AlarmRealtime from '../components/alerts/AlarmRealtime'; import AlarmHistory from '../components/alerts/AlarmHistory'; import AlarmStatistics from '../components/alerts/AlarmStatistics'; import AlarmRules from '../components/alerts/AlarmRules'; import AlarmSubscription from '../components/alerts/AlarmSubscription'; const { Header, Content } = Layout; const { Text } = Typography; export default function AlarmCenterPage() { const [activeTab, setActiveTab] = useState('overview'); const [rawMenuList, setRawMenuList] = useState([]); const [showTabs, setShowTabs] = useState([]); // 获取菜单(和系统设置一模一样) const getMenuListApi = () => { const params = { pageNum: 1, pageSize: 99999 }; return getMenuList(params); }; // 动态生成 tab useEffect(() => { getMenuListApi().then(res => { if (res.code === 200) { const data = res.rows || []; // 告警中心 parentId 你自己改成你数据库里的 ID const alarmChild = data.filter(m => m.parentId == 3388); alarmChild.sort((a, b) => (a.orderNum || 0) - (b.orderNum || 0)); const tabs = alarmChild.map(item => { if (item.path === '/alerts/all') return { key: 'overview', label: '告警总览', icon: }; if (item.path === '/alerts/time') return { key: 'realtime', label: '实时告警', icon: }; if (item.path === '/alerts/history') return { key: 'history', label: '告警历史', icon: }; if (item.path === '/alerts/counts') return { key: 'statistics', label: '告警统计', icon: }; if (item.path === '/alerts/rules') return { key: 'rules', label: '告警规则', icon: }; if (item.path === '/alerts/subscribe') return { key: 'subscription', label: '告警订阅', icon: }; return null; }).filter(Boolean); setShowTabs(tabs); if (tabs.length > 0) setActiveTab(tabs[0].key); } }); }, []); // 渲染对应组件 const renderTabContent = () => { switch (activeTab) { case 'overview': return ; case 'realtime': return ; case 'history': return ; case 'statistics': return ; case 'rules': return ; case 'subscription': return ; default: return
请选择菜单
; } }; return (
告警中心 告警处置闭环、规则管理与事件中心
setActiveTab(key)} items={showTabs} style={{ border: 0, height: 64, lineHeight: '64px' }} />
{renderTabContent()}
); }