123456789101112131415161718192021222324252627282930313233343536
  1. import React from 'react'
  2. import { Menu } from 'antd'
  3. const menuStyle = { height: '100%' }
  4. export default (props) => {
  5. const { theme, items, location } = props
  6. // const selectedKeys = React.useMemo(() => {
  7. // const parts = location.pathname.split('/').filter(Boolean);
  8. // const keys = parts.reduce((acc, it) => {
  9. // const parent = acc.pop();
  10. // const path = !parent ? `/${it}` : `${parent}/${it}`
  11. // return acc.concat([parent, path].filter(Boolean));
  12. // }, []);
  13. // return keys;
  14. // }, [location.pathname]);
  15. // const handClick = (e) => {
  16. // console.log('e', e)
  17. // navigate(`${e.key}`)
  18. // }
  19. const selectedKeys = [location.pathname]
  20. return (
  21. <Menu
  22. // onClick={handClick}
  23. mode="inline"
  24. style={menuStyle}
  25. theme={theme}
  26. items={items}
  27. selectedKeys={selectedKeys}
  28. />
  29. )
  30. }