navbar.jsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import React, { Component } from "react";
  2. import { Route, Switch } from "react-router-dom";
  3. import Overview from "../../components/Overview/overview";
  4. import Stocks from "../../components/StocksApi/stocks";
  5. import IndexApi from "../../components/IndexApi/indexApi";
  6. import indexBasicInfo from "../../components/indexBasicInfo/indexBasicInfo";
  7. import { Link } from "react-router-dom";
  8. import stocksApiList from "../../StocksApiList";
  9. import indexApiList from "../../IndexApiList";
  10. import "antd/dist/antd.css";
  11. import "./navbar.css";
  12. import { Layout, Menu } from "antd";
  13. import {
  14. UserOutlined,
  15. LaptopOutlined,
  16. NotificationOutlined
  17. } from "@ant-design/icons";
  18. const { SubMenu } = Menu;
  19. const { Header, Content, Sider } = Layout;
  20. export default class NavBar extends Component {
  21. constructor(props) {
  22. super(props);
  23. this.state = {
  24. userInfo: {}
  25. };
  26. }
  27. render() {
  28. // let { match } = this.props;
  29. return (
  30. <Layout style={{ minHeight: "100vh" }}>
  31. <Header className="header">BoNiu</Header>
  32. <Layout>
  33. <Sider width={200} className="site-layout-background">
  34. <Menu
  35. mode="inline"
  36. defaultSelectedKeys={["overview"]}
  37. defaultOpenKeys={["overview"]}
  38. style={{ height: "100%", borderRight: 0 }}
  39. >
  40. <Menu.Item key="overview" icon={<UserOutlined />}>
  41. <Link to="/overview">总体说明</Link>
  42. </Menu.Item>
  43. <SubMenu
  44. key="stocks"
  45. icon={<LaptopOutlined />}
  46. title="股票接口"
  47. >
  48. {stocksApiList.map((item) => {
  49. return (
  50. <Menu.Item key={item.key}>
  51. <Link to={item.url}>{item.name}</Link>
  52. </Menu.Item>
  53. );
  54. })}
  55. </SubMenu>
  56. <SubMenu
  57. key="indexApi"
  58. icon={<NotificationOutlined />}
  59. title="指数接口"
  60. >
  61. {indexApiList.map((item) => {
  62. return (
  63. <Menu.Item key={item.key}>
  64. <Link to={{pathname: item.url, state: item.data}}>{item.name}</Link>
  65. </Menu.Item>
  66. );
  67. })}
  68. </SubMenu>
  69. </Menu>
  70. </Sider>
  71. <Layout style={{ padding: "0 24px 24px" }}>
  72. <Content
  73. style={{
  74. background: "#fff",
  75. padding: 24,
  76. margin: 0,
  77. minHeight: 280
  78. }}
  79. >
  80. <Switch>
  81. <Route exact path="/" component={Overview} />
  82. <Route path="/overview" component={Overview} />
  83. <Route path="/stocks" component={Stocks} />
  84. <Route path="/indexApi" component={indexBasicInfo} />
  85. </Switch>
  86. </Content>
  87. </Layout>
  88. </Layout>
  89. </Layout>
  90. );
  91. }
  92. }