Commit 3c2a056e authored by ohhoney1's avatar ohhoney1 Committed by 偏右

fix bug: cannot set light theme correctly

parent a6aebc68
...@@ -2,6 +2,7 @@ import React, { PureComponent } from 'react'; ...@@ -2,6 +2,7 @@ import React, { PureComponent } from 'react';
import { Layout, Menu, Icon } from 'antd'; import { Layout, Menu, Icon } from 'antd';
import pathToRegexp from 'path-to-regexp'; import pathToRegexp from 'path-to-regexp';
import { Link } from 'dva/router'; import { Link } from 'dva/router';
import classNames from 'classnames';
import styles from './index.less'; import styles from './index.less';
import { urlToList } from '../_utils/pathTools'; import { urlToList } from '../_utils/pathTools';
...@@ -75,8 +76,7 @@ export default class SiderMenu extends PureComponent { ...@@ -75,8 +76,7 @@ export default class SiderMenu extends PureComponent {
getDefaultCollapsedSubMenus(props) { getDefaultCollapsedSubMenus(props) {
const { const {
location: { pathname }, location: { pathname },
} = } = props || this.props;
props || this.props;
return getMenuMatchKeys(this.flatMenuKeys, urlToList(pathname)); return getMenuMatchKeys(this.flatMenuKeys, urlToList(pathname));
} }
...@@ -212,6 +212,10 @@ export default class SiderMenu extends PureComponent { ...@@ -212,6 +212,10 @@ export default class SiderMenu extends PureComponent {
render() { render() {
const { logo, menuData, collapsed, onCollapse } = this.props; const { logo, menuData, collapsed, onCollapse } = this.props;
const { openKeys } = this.state; 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 // Don't show popup menu when it is been collapsed
const menuProps = collapsed const menuProps = collapsed
? {} ? {}
...@@ -231,7 +235,7 @@ export default class SiderMenu extends PureComponent { ...@@ -231,7 +235,7 @@ export default class SiderMenu extends PureComponent {
breakpoint="lg" breakpoint="lg"
onCollapse={onCollapse} onCollapse={onCollapse}
width={256} width={256}
className={styles.sider} className={siderClass}
> >
<div className={styles.logo} key="logo"> <div className={styles.logo} key="logo">
<Link to="/"> <Link to="/">
...@@ -241,7 +245,7 @@ export default class SiderMenu extends PureComponent { ...@@ -241,7 +245,7 @@ export default class SiderMenu extends PureComponent {
</div> </div>
<Menu <Menu
key="Menu" key="Menu"
theme="dark" theme={theme}
mode="inline" mode="inline"
{...menuProps} {...menuProps}
onOpenChange={this.handleOpenChange} onOpenChange={this.handleOpenChange}
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35); box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35);
position: relative; position: relative;
z-index: 10; z-index: 10;
&.ligth { &.light {
background-color: white; background-color: white;
.logo { .logo {
background: white; background: white;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment