From 3c2a056ef0dac06ce3b4389192691bb1f5c448e2 Mon Sep 17 00:00:00 2001 From: ohhoney1 <1269075501@qq.com> Date: Mon, 20 Aug 2018 17:20:31 +0800 Subject: [PATCH] fix bug: cannot set light theme correctly --- src/components/SiderMenu/SiderMenu.js | 12 ++++++++---- src/components/SiderMenu/index.less | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/SiderMenu/SiderMenu.js b/src/components/SiderMenu/SiderMenu.js index 8c2f77d1..7ef31536 100644 --- a/src/components/SiderMenu/SiderMenu.js +++ b/src/components/SiderMenu/SiderMenu.js @@ -2,6 +2,7 @@ import React, { PureComponent } from 'react'; import { Layout, Menu, Icon } from 'antd'; import pathToRegexp from 'path-to-regexp'; import { Link } from 'dva/router'; +import classNames from 'classnames'; import styles from './index.less'; import { urlToList } from '../_utils/pathTools'; @@ -75,8 +76,7 @@ export default class SiderMenu extends PureComponent { getDefaultCollapsedSubMenus(props) { const { location: { pathname }, - } = - props || this.props; + } = props || this.props; return getMenuMatchKeys(this.flatMenuKeys, urlToList(pathname)); } @@ -212,6 +212,10 @@ export default class SiderMenu extends PureComponent { render() { const { logo, menuData, collapsed, onCollapse } = this.props; const { openKeys } = this.state; + const theme = 'dark'; + const siderClass = classNames(styles.sider, { + [styles.light]: theme === 'light', + }); // Don't show popup menu when it is been collapsed const menuProps = collapsed ? {} @@ -231,7 +235,7 @@ export default class SiderMenu extends PureComponent { breakpoint="lg" onCollapse={onCollapse} width={256} - className={styles.sider} + className={siderClass} >
@@ -241,7 +245,7 @@ export default class SiderMenu extends PureComponent {