1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
| import "@ant-design/v5-patch-for-react-19";
import React, { useMemo, useState } from "react"; import { VerticalRightOutlined, } from "@ant-design/icons"; import type { MenuProps } from "antd"; import { Breadcrumb, Layout, Menu, theme, Tooltip } from "antd"; import menuLogo from "~/assets/menu-logo.svg"; import menuLogoSlim from "~/assets/menu-logo-slim.svg"; import { Outlet, useLocation, useNavigate } from "react-router"; import { items } from "./scripts/menus"; const { Header, Content, Footer, Sider } = Layout;
export const VerticalDashboardLayout: React.FC = () => { const [collapsed, setCollapsed] = useState(false); const { token: { colorBgContainer, borderRadiusLG }, } = theme.useToken(); const location = useLocation();
const selectedMenuItems: string[] = useMemo(() => { return [location.pathname]; }, [location.pathname]); const navigate = useNavigate();
const handleMenuClick: MenuProps["onClick"] = ({ key }) => { navigate(key); };
return ( <Layout className="h-screen"> <Sider trigger={null} collapsible width={250} collapsed={collapsed} className="h-screen overflow-y-auto scrollbar-hide" > <div className="demo-logo-vertical relative pb-1 pt-1"> <div className={`absolute top-0.5 right-0.5 text-[#e8e8e8] cursor-pointer ${collapsed && "hidden"}`} > <VerticalRightOutlined onClick={() => setCollapsed(true)} /> </div> <img src={menuLogo} alt="React Router" className={`block w-full ${collapsed && "hidden"}`} /> <Tooltip title="Expand Menu"> <img src={menuLogoSlim} alt="React Router" className={`block w-full ${collapsed || "hidden"} cursor-pointer`} onClick={() => setCollapsed(false)} /> </Tooltip> </div> <Menu theme="dark" selectedKeys={selectedMenuItems} defaultSelectedKeys={["/dashboard"]} mode="inline" items={items} onClick={handleMenuClick} /> </Sider> <Layout className="h-screen overflow-auto"> <Header style={{ padding: 0, background: colorBgContainer }} /> <Content style={{ margin: "0 16px", paddingTop: "16px" }}> <div style={{ padding: 24, minHeight: 360, background: colorBgContainer, borderRadius: borderRadiusLG, }} > <Outlet /> </div> </Content> <Footer style={{ textAlign: "center" }}> Copyright ©{new Date().getFullYear()} Created by OpenGMS </Footer> </Layout> </Layout> ); };
import { SettingOutlined, TeamOutlined, AuditOutlined, UserOutlined, DatabaseOutlined, ConsoleSqlOutlined, ControlOutlined, FileProtectOutlined, GlobalOutlined, BlockOutlined, ClearOutlined, ProductOutlined, DashboardOutlined, VerticalRightOutlined, InboxOutlined, } from "@ant-design/icons"; import type { MenuProps } from "antd"; type MenuItem = Required<MenuProps>["items"][number];
export const items: MenuItem[] = [ { key: "/dashboard", label: "工作台", icon: <DashboardOutlined />, }, { key: "1", label: "用户", type: "group", children: [ { key: "/user", label: "用户管理", icon: <UserOutlined />, }, { key: "/role", label: "角色管理", icon: <TeamOutlined />, }, { key: "/permission", label: "权限配置", icon: <AuditOutlined />, }, ], }, { key: "2", label: "数据", type: "group", children: [ { key: "/sensor", label: "传感器信息管理", icon: <GlobalOutlined />, }, { key: "/product", label: "产品信息管理", icon: <InboxOutlined />, }, { key: "/satellite", label: "遥感数据管理", icon: <DatabaseOutlined />, }, { key: "/vector", label: "矢量数据管理", icon: <BlockOutlined />, }, { key: "/theme", label: "栅格产品管理", icon: <ProductOutlined />, }, ], }, { key: "3", label: "运维", type: "group", children: [ { key: "/cache", label: "缓存管理", icon: <ClearOutlined />, }, { key: "/sql", label: "SQL监控", icon: <ConsoleSqlOutlined />, }, { key: "/audit", label: "日志审查", icon: <FileProtectOutlined />, }, { key: "/task", label: "任务管理", icon: <ControlOutlined />, }, ], }, { key: "4", label: "配置", type: "group", children: [ { key: "/config", label: "系统参数", icon: <SettingOutlined />, }, ], }, ];
import type { Route } from "./+types/dashboard"; import { VerticalDashboardLayout } from "../layouts/vertical-dashboard"
export function meta({}: Route.MetaArgs) { return [ { title: "ARD后台管理系统" }, { name: "description", content: "Welcome to React Router!" }, ]; }
export default function Dashboard() { return ( <> <VerticalDashboardLayout /> </> ); }
import type { Route } from "./+types/home"; import { useEffect } from "react"; import { useNavigate } from "react-router";
export function meta({}: Route.MetaArgs) { return [ { title: "New React Router App" }, { name: "description", content: "Welcome to React Router!" }, ]; }
export default function Home() { const navigate = useNavigate(); useEffect(() => { navigate("/dashboard") }); return null; }
|