Browse Source

tweak code to keep coding style consistency

pull/1483/head
Alan Wei 9 years ago
committed by 陈帅
parent
commit
fad3f4ac7c
  1. 25
      src/components/SiderMenu/SiderMenu.js

25
src/components/SiderMenu/SiderMenu.js

@ -28,13 +28,14 @@ const getIcon = icon => {
* @param menu
*/
export const getFlatMenuKeys = menu =>
menu.reduce((keys, item) => {
keys.push(item.path);
if (item.children) {
return keys.concat(getFlatMenuKeys(item.children));
}
return keys;
}, []);
menu
.reduce((keys, item) => {
keys.push(item.path);
if (item.children) {
return keys.concat(getFlatMenuKeys(item.children));
}
return keys;
}, []);
/**
* Find all matched menu keys based on paths
@ -42,11 +43,11 @@ export const getFlatMenuKeys = menu =>
* @param paths: [/abc, /abc/11, /abc/11/info]
*/
export const getMeunMatchKeys = (flatMenuKeys, paths) =>
paths.reduce(
(matchKeys, path) =>
matchKeys.concat(flatMenuKeys.filter(item => pathToRegexp(item).test(path))),
[]
);
paths
.reduce((matchKeys, path) => (
matchKeys.concat(
flatMenuKeys.filter(item => pathToRegexp(item).test(path))
)), []);
export default class SiderMenu extends PureComponent {
constructor(props) {

Loading…
Cancel
Save