zuiidea / antd-admin

An excellent front-end solution for enterprise applications built upon Ant Design and UmiJS

Home Page:https://antd-admin.zuiidea.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

地址栏手动更改路由(pathname),侧边栏没有匹配高亮

jiangbo2015 opened this issue · comments

内容跟着换了,侧边栏没有匹配高亮效果,还是上一个路由的高亮

componentWillMount() {
        let { keys, values, entries } = Object
        const pathname = this.props.location.pathname
        const _current = pathname === '/' ? introduce : pathname.substr(0, 1) === '/' ? pathname.substr(1) : pathname
        const hasKeys = SideMenus.filter(value => {
            return value.key !== _current && value.groups
        })
        let findKyes = []
        if (hasKeys.length > 0) {
            findKyes = hasKeys.filter(value => {
                for (let value of values(value.groups)) {
                    return value.key === _current
                }
            })
        }
        let _openKeys = []
        findKyes.length > 0 ? _openKeys.push(findKyes[0].key) : _openKeys.push('introduce')
        this.setState({ current: _current, openKeys: _openKeys });
    }

本人是这么处理的,不太优雅