cl 4 years ago
parent
commit
33104cdec6
2 changed files with 32 additions and 6 deletions
  1. 1 1
      boniu/.eslintcache
  2. 31 5
      boniu/src/components/Navbar/navbar.jsx

File diff suppressed because it is too large
+ 1 - 1
boniu/.eslintcache


+ 31 - 5
boniu/src/components/Navbar/navbar.jsx

@@ -20,7 +20,9 @@ class NavBar extends Component {
     super(props);
     this.state = {
       userInfo: {},
-      opensubmenu: ["overview"]
+      opensubmenu: ["overview"],
+      stocks: null,
+      index: null
     };
   }
   render() {
@@ -51,9 +53,19 @@ class NavBar extends Component {
                   opensubmenu: item
                 });
                 item.slice(-1)[0] === "indexApi"
+                  ? this.state.index
+                    ? this.props.history.push({
+                        pathname: this.state.index.url,
+                        state: this.state.index
+                      })
+                    : this.props.history.push({
+                        pathname: indexApiList[0].url,
+                        state: indexApiList[0]
+                      })
+                  : this.state.stocks
                   ? this.props.history.push({
-                      pathname: indexApiList[0].url,
-                      state: indexApiList[0]
+                      pathname: this.state.stocks.url,
+                      state: this.state.stocks
                     })
                   : this.props.history.push({
                       pathname: stocksApiList[0].url,
@@ -67,7 +79,14 @@ class NavBar extends Component {
               <SubMenu key="stocks" icon={<LaptopOutlined />} title="股票接口">
                 {stocksApiList.map((item) => {
                   return (
-                    <Menu.Item key={item.key}>
+                    <Menu.Item
+                      key={item.key}
+                      onClick={() => {
+                        this.setState({
+                          stocks: item
+                        });
+                      }}
+                    >
                       <Link to={{ pathname: item.url, state: item }}>
                         {item.name}
                       </Link>
@@ -82,7 +101,14 @@ class NavBar extends Component {
               >
                 {indexApiList.map((item) => {
                   return (
-                    <Menu.Item key={item.key}>
+                    <Menu.Item
+                      key={item.key}
+                      onClick={() => {
+                        this.setState({
+                          index: item
+                        });
+                      }}
+                    >
                       <Link to={{ pathname: item.url, state: item }}>
                         {item.name}
                       </Link>