LeftSider.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import { Link } from "react-router-dom";
  2. import type { MenuProps } from "antd";
  3. import { Affix, Layout } from "antd";
  4. import { Menu } from "antd";
  5. import { AppstoreOutlined, HomeOutlined } from "@ant-design/icons";
  6. const { Sider } = Layout;
  7. const onClick: MenuProps["onClick"] = (e) => {
  8. console.log("click ", e);
  9. };
  10. type IWidgetHeadBar = {
  11. selectedKeys?: string;
  12. };
  13. const LeftSiderWidget = ({ selectedKeys = "" }: IWidgetHeadBar) => {
  14. const items: MenuProps["items"] = [
  15. {
  16. label: "API",
  17. key: "api",
  18. icon: <HomeOutlined />,
  19. children: [
  20. {
  21. label: <Link to="/admin/api/dashboard">dashboard</Link>,
  22. key: "dashboard",
  23. },
  24. ],
  25. },
  26. {
  27. label: "管理",
  28. key: "manage",
  29. icon: <HomeOutlined />,
  30. children: [
  31. {
  32. label: <Link to="/admin/relation/list">Relation</Link>,
  33. key: "relation",
  34. },
  35. {
  36. label: <Link to="/admin/nissaya-ending/list">Nissaya Ending</Link>,
  37. key: "nissaya-ending",
  38. },
  39. {
  40. label: "Dictionary",
  41. key: "dict",
  42. children: [
  43. {
  44. label: <Link to="/admin/dictionary/list">List</Link>,
  45. key: "list",
  46. },
  47. {
  48. label: <Link to="/admin/dictionary/preference">Preference</Link>,
  49. key: "preference",
  50. },
  51. ],
  52. },
  53. {
  54. label: <Link to="/admin/users/list">users</Link>,
  55. key: "users",
  56. },
  57. {
  58. label: <Link to="/admin/invite/list">invite</Link>,
  59. key: "invite",
  60. },
  61. ],
  62. },
  63. {
  64. label: "统计",
  65. key: "advance",
  66. icon: <AppstoreOutlined />,
  67. children: [],
  68. },
  69. ];
  70. return (
  71. <Affix offsetTop={0}>
  72. <Sider width={200} breakpoint="lg" className="site-layout-background">
  73. <Menu
  74. theme="light"
  75. onClick={onClick}
  76. defaultSelectedKeys={[selectedKeys]}
  77. defaultOpenKeys={["basic", "advance", "collaboration"]}
  78. mode="inline"
  79. items={items}
  80. />
  81. </Sider>
  82. </Affix>
  83. );
  84. };
  85. export default LeftSiderWidget;