正在显示
1 个修改的文件
包含
1 行增加
和
15 行删除
| 1 | import React, { Component } from 'react'; | 1 | import React, { Component } from 'react'; |
| 2 | import { connect } from 'dva'; | 2 | import { connect } from 'dva'; |
| 3 | -import router from 'umi/router'; | ||
| 4 | import { FormattedMessage } from 'umi/locale'; | 3 | import { FormattedMessage } from 'umi/locale'; |
| 5 | import { Menu } from 'antd'; | 4 | import { Menu } from 'antd'; |
| 6 | import styles from './style.less'; | 5 | import styles from './style.less'; |
| @@ -17,7 +16,6 @@ const { Item } = Menu; | @@ -17,7 +16,6 @@ const { Item } = Menu; | ||
| 17 | class PAGE_NAME_UPPER_CAMEL_CASE extends Component { | 16 | class PAGE_NAME_UPPER_CAMEL_CASE extends Component { |
| 18 | constructor(props) { | 17 | constructor(props) { |
| 19 | super(props); | 18 | super(props); |
| 20 | - const { match, location } = props; | ||
| 21 | const menuMap = { | 19 | const menuMap = { |
| 22 | base: <FormattedMessage id="BLOCK_BAME.menuMap.basic" defaultMessage="Basic Settings" />, | 20 | base: <FormattedMessage id="BLOCK_BAME.menuMap.basic" defaultMessage="Basic Settings" />, |
| 23 | security: ( | 21 | security: ( |
| @@ -33,24 +31,13 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends Component { | @@ -33,24 +31,13 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends Component { | ||
| 33 | /> | 31 | /> |
| 34 | ), | 32 | ), |
| 35 | }; | 33 | }; |
| 36 | - const key = location.pathname.replace(`${match.path}/`, ''); | ||
| 37 | this.state = { | 34 | this.state = { |
| 38 | mode: 'inline', | 35 | mode: 'inline', |
| 39 | menuMap, | 36 | menuMap, |
| 40 | - selectKey: menuMap[key] ? key : 'base', | 37 | + selectKey: 'base', |
| 41 | }; | 38 | }; |
| 42 | } | 39 | } |
| 43 | 40 | ||
| 44 | - static getDerivedStateFromProps(props, state) { | ||
| 45 | - const { location } = props; | ||
| 46 | - let selectKey = location.pathname.split('/').pop(); | ||
| 47 | - selectKey = state.menuMap[selectKey] ? selectKey : 'base'; | ||
| 48 | - if (selectKey !== state.selectKey) { | ||
| 49 | - return { selectKey }; | ||
| 50 | - } | ||
| 51 | - return null; | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | componentDidMount() { | 41 | componentDidMount() { |
| 55 | const { dispatch } = this.props; | 42 | const { dispatch } = this.props; |
| 56 | dispatch({ | 43 | dispatch({ |
| @@ -75,7 +62,6 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends Component { | @@ -75,7 +62,6 @@ class PAGE_NAME_UPPER_CAMEL_CASE extends Component { | ||
| 75 | }; | 62 | }; |
| 76 | 63 | ||
| 77 | selectKey = ({ key }) => { | 64 | selectKey = ({ key }) => { |
| 78 | - router.push(`/account/settings/${key}`); | ||
| 79 | this.setState({ | 65 | this.setState({ |
| 80 | selectKey: key, | 66 | selectKey: key, |
| 81 | }); | 67 | }); |
请
注册
或
登录
后发表评论