|
|
@@ -2,7 +2,7 @@ import React, { Component } from "react";
|
|
|
import { Route, Switch, Link, withRouter } from "react-router-dom";
|
|
|
import Overview from "../../components/Overview/overview";
|
|
|
import indexBasicInfo from "../../components/indexBasicInfo/indexBasicInfo";
|
|
|
-import stocksInfo from '../../components/StocksInfo/stocksInfo'
|
|
|
+import stocksInfo from "../../components/StocksInfo/stocksInfo";
|
|
|
import stocksApiList from "../../StocksApiList";
|
|
|
import indexApiList from "../../IndexApiList";
|
|
|
import "antd/dist/antd.css";
|
|
|
@@ -19,19 +19,10 @@ class NavBar extends Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
- userInfo: {}
|
|
|
+ userInfo: {},
|
|
|
+ opensubmenu: ["overview"]
|
|
|
};
|
|
|
}
|
|
|
- clickHandler = (arr) => {
|
|
|
- const stocks = stocksApiList[0]
|
|
|
- const index = indexApiList[0]
|
|
|
- console.log(arr)
|
|
|
- if (arr.includes('stocks')) {
|
|
|
- this.props.history.push({pathname: stocks.url, state: stocks})
|
|
|
- } else if (arr.includes('indexApi')) {
|
|
|
- this.props.history.push({pathname: index.url, state: index})
|
|
|
- }
|
|
|
- }
|
|
|
render() {
|
|
|
// let { match } = this.props;
|
|
|
const pathNames = this.props.history.location.pathname;
|
|
|
@@ -44,12 +35,31 @@ class NavBar extends Component {
|
|
|
<Layout>
|
|
|
<Sider width={200} className="site-layout-background">
|
|
|
<Menu
|
|
|
- onOpenChange={ (arr) => this.clickHandler(arr) }
|
|
|
mode="inline"
|
|
|
defaultSelectedKeys={["overview"]}
|
|
|
defaultOpenKeys={["overview"]}
|
|
|
style={{ height: "100%", borderRight: 0 }}
|
|
|
selectedKeys={pathNames}
|
|
|
+ onOpenChange={(item) => {
|
|
|
+ if (item.length < this.state.opensubmenu.length) {
|
|
|
+ this.setState({
|
|
|
+ opensubmenu: item
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.setState({
|
|
|
+ opensubmenu: item
|
|
|
+ });
|
|
|
+ item.slice(-1)[0] === "indexApi"
|
|
|
+ ? this.props.history.push({
|
|
|
+ pathname: indexApiList[0].url,
|
|
|
+ state: indexApiList[0]
|
|
|
+ })
|
|
|
+ : this.props.history.push({
|
|
|
+ pathname: stocksApiList[0].url,
|
|
|
+ state: stocksApiList[0]
|
|
|
+ });
|
|
|
+ }}
|
|
|
>
|
|
|
<Menu.Item key="overview" icon={<UserOutlined />}>
|
|
|
<Link to="/overview">总体说明</Link>
|