二级菜单配置
This commit is contained in:
@@ -19,51 +19,16 @@ 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: <AlertOutlined /> };
|
||||
if (item.path === '/alerts/time') return { key: 'realtime', label: '实时告警', icon: <ClockCircleOutlined /> };
|
||||
if (item.path === '/alerts/history') return { key: 'history', label: '告警历史', icon: <FileTextOutlined /> };
|
||||
if (item.path === '/alerts/counts') return { key: 'statistics', label: '告警统计', icon: <BarChartOutlined /> };
|
||||
if (item.path === '/alerts/rules') return { key: 'rules', label: '告警规则', icon: <SettingOutlined /> };
|
||||
if (item.path === '/alerts/subscribe') return { key: 'subscription', label: '告警订阅', icon: <BellOutlined /> };
|
||||
return null;
|
||||
}).filter(Boolean);
|
||||
|
||||
setShowTabs(tabs);
|
||||
if (tabs.length > 0) setActiveTab(tabs[0].key);
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
// 渲染对应组件
|
||||
const renderTabContent = () => {
|
||||
switch (activeTab) {
|
||||
case 'overview': return <AlarmOverview />;
|
||||
case 'realtime': return <AlarmRealtime />;
|
||||
case 'history': return <AlarmHistory />;
|
||||
case 'statistics': return <AlarmStatistics />;
|
||||
case 'rules': return <AlarmRules />;
|
||||
case 'subscription': return <AlarmSubscription />;
|
||||
default: return <div style={{ padding: 20 }}><Text>请选择菜单</Text></div>;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user