url active menu

This commit is contained in:
zuiidea
2016-12-03 23:46:22 +08:00
parent 3d8a952f5f
commit 5258670e86
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -28,7 +28,8 @@ const getMenus = function (menuArray,siderFold,parentPath) {
})
}
function Sider({ siderFold,darkTheme,changeTheme }) {
function Sider({ siderFold,darkTheme,location,changeTheme }) {
console.log(location);
return (
<div>
<div className={styles.logo}>
@@ -38,7 +39,7 @@ function Sider({ siderFold,darkTheme,changeTheme }) {
<Menu
mode={siderFold?"vertical":"inline"}
theme={darkTheme?"dark":"light"}
defaultSelectedKeys={['dashboard']}>
defaultSelectedKeys={[location.pathname.split('/')[location.pathname.split('/').length - 1]||'dashboard']}>
{getMenus(menu,siderFold)}
</Menu>
{!siderFold?<div className={styles.switchtheme}>
+1 -1
View File
@@ -22,7 +22,6 @@ function App({children, location, dispatch, app}) {
const headerProps = {
user,
location,
siderFold,
logout() {
dispatch({type: 'app/logout'})
@@ -35,6 +34,7 @@ function App({children, location, dispatch, app}) {
const siderProps = {
siderFold,
darkTheme,
location,
changeTheme(){
dispatch({type: 'app/changeTheme'})
}