Commit 3cc9cb18 authored by 曾婧's avatar 曾婧

fix: hn主题菜单保持只展开一个子菜单

parent b259eef9
......@@ -5,6 +5,7 @@ import { ReactSVG } from 'react-svg';
import useMergedState from 'rc-util/lib/hooks/useMergedState';
import { useHistory } from '@wisdom-utils/runtime';
import ProLayout, { getPageTitle } from '@ant-design/pro-layout';
import { findPathByWidget } from '@wisdom-utils/components/lib/AppLayout/helpers';
const LoadingSkeleton = props => {
const { route } = props;
return (
......@@ -17,9 +18,10 @@ const LoadingSkeleton = props => {
};
const Menu = props => {
const { prefixCls, collapsed, onCollapse, onMenuClick, menuHeaderRender, onMenuHeaderClick } = props;
const [pathname, setPathname] = useState('');
const { route } = props;
const history = useHistory();
const [activeMenu, setActiveMenu] = useState("首页");
const [activeMenu, setActiveMenu] = useState('首页');
const [sunRoute, setsunRoute] = useState(route);
const [selectIndex, setSelectIndex] = useMergedState(() => -1, {
value: props.active,
......@@ -43,7 +45,7 @@ const Menu = props => {
current = item;
childrenRoutes = [item];
}
setPathname(current.path);
setSelectIndex(index);
if (/iframe/.test(current.path)) {
history.push({
......@@ -55,16 +57,13 @@ const Menu = props => {
}
onMenuClick && onMenuClick(current, childrenRoutes, index);
};
useEffect(() => {
let all=props.flatMenu;
all.forEach((it)=>{
if(it.path===props.location.pathname){
setActiveMenu(it.name)
return;
}
})
}, [props.location.pathname]);
useEffect(()=>{
var allWidgets = window.globalConfig && window.globalConfig.allWidgets;
let homgUrl=props.config && props.config.homepage.replace(/(civ_energy\/)/g,'');
let curItem = findPathByWidget(homgUrl, allWidgets, '', 'url');
curItem&&setActiveMenu(curItem.label);
curItem&&setPathname(curItem.path)
},[])
useEffect(() => {
if (route && route.routes) {
setsunRoute(route);
......@@ -120,6 +119,9 @@ const Menu = props => {
defaultCollapsed={false}
collapsed={false}
breakpoint={'xs'}
location={{
pathname,
}}
// onHeaderLogo={handlerIndustry}
// onPageChange={handlerPageChange}
// onMenuPanelItemClick={handleUpdateCurrentIndex}
......@@ -188,7 +190,7 @@ export default props => {
// className={classNames(`${prefixCls}`, `${prefixCls}-fixed`, {
// [`${prefixCls}-collapsed`]: collapsed,
// })}
style={{paddingTop:'50px'}}
style={{ paddingTop: '50px' }}
>
<div className={`${prefixCls}-children`}>
<div className={`${prefixCls}-wrapper`} style={{ flex: '1 1 0%', overflow: 'hidden auto' }}>
......
......@@ -9,6 +9,9 @@
}
.hnlayout {
:global {
.@{ant-prefix}-menu-dark.@{ant-prefix}-menu-dark:not(.@{ant-prefix}-menu-horizontal) .@{ant-prefix}-menu-item-selected{
background: transparent!important;
}
.@{ant-prefix}-global-page-header-header {
padding-left: 0;
}
......
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