forked from linkong/planet
feat: ship persistent ai playground and alerts foundation
This commit is contained in:
1 parent
60f5ff9bab
commit
89a71e6f29
31 files changed
+4754
-669
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { ReactNode, useState } from 'react'
|
||||
import { ReactNode, useMemo, useState } from 'react'
|
||||
import { Layout, Menu, Typography, Button, Space } from 'antd'
|
||||
import {
|
||||
AlertOutlined,
|
||||
DashboardOutlined,
|
||||
DatabaseOutlined,
|
||||
UserOutlined,
|
||||
@@ -10,8 +11,13 @@ import {
|
||||
RobotOutlined,
|
||||
MenuUnfoldOutlined,
|
||||
MenuFoldOutlined,
|
||||
GlobalOutlined,
|
||||
AppstoreOutlined,
|
||||
ToolOutlined,
|
||||
InboxOutlined,
|
||||
} from '@ant-design/icons'
|
||||
import { useLocation, useNavigate } from 'react-router-dom'
|
||||
import type { ItemType, MenuItemType } from 'antd/es/menu/interface'
|
||||
import { useAuthStore } from '../../stores/auth'
|
||||
import packageJson from '../../../package.json'
|
||||
|
||||
@@ -27,19 +33,64 @@ function AppLayout({ children }: AppLayoutProps) {
|
||||
const navigate = useNavigate()
|
||||
const { user, logout } = useAuthStore()
|
||||
const [collapsed, setCollapsed] = useState(false)
|
||||
const [openKeys, setOpenKeys] = useState<string[]>(['collection'])
|
||||
const showBanner = true
|
||||
const appVersion = `v${packageJson.version}`
|
||||
|
||||
const menuItems = [
|
||||
{ key: '/admin', icon: <DashboardOutlined />, label: '仪表盘' },
|
||||
{ key: '/datasources', icon: <DatabaseOutlined />, label: '数据源' },
|
||||
{ key: '/data', icon: <BarChartOutlined />, label: '采集数据' },
|
||||
{ key: '/bgp', icon: <DeploymentUnitOutlined />, label: 'BGP观测' },
|
||||
{ key: '/playground', icon: <RobotOutlined />, label: 'AI Playground' },
|
||||
{ key: '/users', icon: <UserOutlined />, label: '用户管理' },
|
||||
{ key: '/settings', icon: <SettingOutlined />, label: '系统配置' },
|
||||
const menuItems: ItemType<MenuItemType>[] = [
|
||||
{
|
||||
key: 'overview',
|
||||
icon: <DashboardOutlined />,
|
||||
label: '总览',
|
||||
children: [
|
||||
{ key: '/admin', icon: <DashboardOutlined />, label: '仪表盘' },
|
||||
{ key: '/earth', icon: <GlobalOutlined />, label: 'Earth' },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'collection',
|
||||
icon: <InboxOutlined />,
|
||||
label: '采集与数据',
|
||||
children: [
|
||||
{ key: '/datasources', icon: <DatabaseOutlined />, label: '数据源' },
|
||||
{ key: '/data', icon: <BarChartOutlined />, label: '采集数据' },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'observability',
|
||||
icon: <AppstoreOutlined />,
|
||||
label: '专题观测',
|
||||
children: [
|
||||
{ key: '/bgp', icon: <DeploymentUnitOutlined />, label: 'BGP观测' },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'alerts',
|
||||
icon: <AlertOutlined />,
|
||||
label: '告警与研判',
|
||||
children: [
|
||||
{ key: '/alerts/system', icon: <AlertOutlined />, label: '系统告警' },
|
||||
{ key: '/alerts/bgp', icon: <DeploymentUnitOutlined />, label: 'BGP 告警' },
|
||||
{ key: '/alerts/situational', icon: <GlobalOutlined />, label: '态势告警' },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'ops',
|
||||
icon: <ToolOutlined />,
|
||||
label: '运维与配置',
|
||||
children: [
|
||||
{ key: '/playground', icon: <RobotOutlined />, label: 'AI Playground' },
|
||||
{ key: '/users', icon: <UserOutlined />, label: '用户管理' },
|
||||
{ key: '/settings', icon: <SettingOutlined />, label: '系统配置' },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
const selectedKey = useMemo(() => {
|
||||
if (location.pathname === '/') return '/earth'
|
||||
return location.pathname
|
||||
}, [location.pathname])
|
||||
|
||||
return (
|
||||
<Layout className="dashboard-layout">
|
||||
<Sider
|
||||
@@ -47,7 +98,12 @@ function AppLayout({ children }: AppLayoutProps) {
|
||||
collapsedWidth={72}
|
||||
collapsible
|
||||
collapsed={collapsed}
|
||||
onCollapse={setCollapsed}
|
||||
onCollapse={(nextCollapsed) => {
|
||||
setCollapsed(nextCollapsed)
|
||||
if (nextCollapsed) {
|
||||
setOpenKeys([])
|
||||
}
|
||||
}}
|
||||
className="dashboard-sider"
|
||||
>
|
||||
<div className="dashboard-sider-inner">
|
||||
@@ -69,10 +125,14 @@ function AppLayout({ children }: AppLayoutProps) {
|
||||
<Menu
|
||||
theme="dark"
|
||||
mode="inline"
|
||||
selectedKeys={[location.pathname]}
|
||||
selectedKeys={[selectedKey]}
|
||||
openKeys={collapsed ? [] : openKeys}
|
||||
items={menuItems}
|
||||
onOpenChange={(keys) => {
|
||||
setOpenKeys(keys as string[])
|
||||
}}
|
||||
onClick={({ key }) => {
|
||||
if (key !== location.pathname) {
|
||||
if (key !== selectedKey) {
|
||||
navigate(key)
|
||||
}
|
||||
}}
|
||||
|
||||
Reference in new issue
Block a user