Commit 118764ae authored by 曾婧's avatar 曾婧

fix: 华农菜单栏

parent 414052e4
...@@ -19,7 +19,7 @@ const Menu = props => { ...@@ -19,7 +19,7 @@ const Menu = props => {
const { prefixCls, collapsed, onCollapse, onMenuClick, menuHeaderRender, onMenuHeaderClick } = props; const { prefixCls, collapsed, onCollapse, onMenuClick, menuHeaderRender, onMenuHeaderClick } = props;
const { route } = props; const { route } = props;
const history = useHistory(); const history = useHistory();
const [activeMenu, setActiveMenu] = useState('首页'); const [activeMenu, setActiveMenu] = useState("首页");
const [sunRoute, setsunRoute] = useState(route); const [sunRoute, setsunRoute] = useState(route);
const [selectIndex, setSelectIndex] = useMergedState(() => -1, { const [selectIndex, setSelectIndex] = useMergedState(() => -1, {
value: props.active, value: props.active,
...@@ -55,6 +55,16 @@ const Menu = props => { ...@@ -55,6 +55,16 @@ const Menu = props => {
} }
onMenuClick && onMenuClick(current, childrenRoutes, index); 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(() => { useEffect(() => {
if (route && route.routes) { if (route && route.routes) {
setsunRoute(route); setsunRoute(route);
...@@ -120,7 +130,9 @@ const Menu = props => { ...@@ -120,7 +130,9 @@ const Menu = props => {
[`hight-active`]: item.name === activeMenu, [`hight-active`]: item.name === activeMenu,
})} })}
> >
{item.extData.icon=='1'?(<span></span>):/.svg/.test(item.extData.icon) ? ( {item.extData.icon == '1' ? (
<span />
) : /.svg/.test(item.extData.icon) ? (
<div className="my-svg"> <div className="my-svg">
<ReactSVG src={item.extData.icon} style={{ width: '100%', height: '100%' }} /> <ReactSVG src={item.extData.icon} style={{ width: '100%', height: '100%' }} />
</div> </div>
...@@ -138,11 +150,13 @@ const Menu = props => { ...@@ -138,11 +150,13 @@ const Menu = props => {
} }
subMenuItemRender={(item, dom) => ( subMenuItemRender={(item, dom) => (
<div className={classNames(`test-icon`)}> <div className={classNames(`test-icon`)}>
{item.extData.icon=='1'?(<span></span>):/.svg/.test(item.extData.icon) ? ( {item.extData.icon == '1' ? (
<span />
) : /.svg/.test(item.extData.icon) ? (
<div className="my-svg"> <div className="my-svg">
<ReactSVG src={item.extData.icon} style={{ width: '100%', height: '100%' }} /> <ReactSVG src={item.extData.icon} style={{ width: '100%', height: '100%' }} />
</div> </div>
) :( ) : (
<div className="my-img"> <div className="my-img">
<img src={item.extData.icon} style={{ width: '100%', height: '100%' }} /> <img src={item.extData.icon} style={{ width: '100%', height: '100%' }} />
</div> </div>
......
...@@ -107,7 +107,7 @@ const Index = props => { ...@@ -107,7 +107,7 @@ const Index = props => {
<> <>
{item.icon ? ( {item.icon ? (
item.icon item.icon
) : item.extData && item.extData.icon == '1' ? ( ) : item.extData && item.extData.icon === '1' ? (
<span /> <span />
) : /.svg/.test(item.extData.icon) ? ( ) : /.svg/.test(item.extData.icon) ? (
<ReactSVG src={item.extData.icon} style={{ width: '18px', height: '18px' }} /> <ReactSVG src={item.extData.icon} style={{ width: '18px', height: '18px' }} />
......
...@@ -20,6 +20,8 @@ import RouteContext from '@wisdom-utils/components/lib/AppLayout/layouts/RouteCo ...@@ -20,6 +20,8 @@ import RouteContext from '@wisdom-utils/components/lib/AppLayout/layouts/RouteCo
import { getPageTitleInfo } from '@wisdom-utils/components/lib/AppLayout/layouts/getPageTitle'; import { getPageTitleInfo } from '@wisdom-utils/components/lib/AppLayout/layouts/getPageTitle';
import omit from 'omit.js'; import omit from 'omit.js';
import classNames from 'classnames'; import classNames from 'classnames';
import { connect } from 'react-redux';
import { withRouter } from '@wisdom-utils/runtime';
import useDocumentTitle from '@wisdom-utils/components/lib/AppLayout/layouts/hooks/useDocumentTitle'; import useDocumentTitle from '@wisdom-utils/components/lib/AppLayout/layouts/hooks/useDocumentTitle';
import defaultSettings from '@wisdom-utils/components/lib/AppLayout/layouts/defaultSettings'; import defaultSettings from '@wisdom-utils/components/lib/AppLayout/layouts/defaultSettings';
import isBrowser from '@wisdom-utils/components/lib/AppLayout/layouts/utils/isBrowser'; import isBrowser from '@wisdom-utils/components/lib/AppLayout/layouts/utils/isBrowser';
...@@ -87,7 +89,7 @@ const renderSiderMenu = (props) => { ...@@ -87,7 +89,7 @@ const renderSiderMenu = (props) => {
if (menuRender === false) { if (menuRender === false) {
return null; return null;
} }
const defaultDom = <SlideMenu {...props} />; const defaultDom = <SlideMenu {...props}/>;
if (menuRender) { if (menuRender) {
return menuRender(props, defaultDom); return menuRender(props, defaultDom);
...@@ -259,6 +261,25 @@ const BasicLayout = (props) => { ...@@ -259,6 +261,25 @@ const BasicLayout = (props) => {
setCurrentRoute(newRoutes); setCurrentRoute(newRoutes);
} }
}, [route, currentMenuIndex]); }, [route, currentMenuIndex]);
useEffect(() => {
let all=props.flatMenu;
let currentObj;
all.forEach((it)=>{
if(it.path===props.location.pathname){
currentObj=it;
setSubRoutes([
{
extData: currentObj.extData,
path: `${currentObj.path}`,
name: `${currentObj.name}`,
},
]);
setTabActiveKey(currentObj.path);
return;
}
})
}, [props.location.pathname]);
useEffect(() => { useEffect(() => {
const initSelectRoute = findPathByLeafId( const initSelectRoute = findPathByLeafId(
...@@ -362,23 +383,31 @@ const BasicLayout = (props) => { ...@@ -362,23 +383,31 @@ const BasicLayout = (props) => {
}, []); }, []);
useEffect(() => { useEffect(() => {
if (selectIndex !== -1 && currentRoute && currentRoute.hasOwnProperty('routes')) { // if (selectIndex !== -1 && currentRoute && currentRoute.hasOwnProperty('routes')) {
const routes = currentRoute.routes[selectIndex]; // const routes = currentRoute.routes[selectIndex];
if (routes) { // setSubRoutes([
if (routes && routes.routes) { // {
const route = // icon: currentObj.extData.icon,
routes && // path: `${currentObj.path}`,
routes.routes && // name: `${currentObj.name}`,
routes.routes.find( // },
(item) => item.path === decodeURI(window.location.pathname.replace('/civbase', '')), // ]);
); // if (routes) {
if (route && route.path) { // if (routes && routes.routes) {
setTabActiveKey(route.path); // const route =
} // routes &&
} // routes.routes &&
} // routes.routes.find(
} // (item) => item.path === decodeURI(window.location.pathname.replace('/civbase', '')),
onPageChange && onPageChange(props.location); // );
// if (route && route.path) {
// console.log('route000000000',route)
// setTabActiveKey(route.path);
// }
// }
// }
// }
// onPageChange && onPageChange(props.location);
}, [props.location, location.pathname.search]); }, [props.location, location.pathname.search]);
useDocumentTitle(pageTitleInfo, props.title || false); useDocumentTitle(pageTitleInfo, props.title || false);
...@@ -470,5 +499,29 @@ BasicLayout.defaultProps = { ...@@ -470,5 +499,29 @@ BasicLayout.defaultProps = {
...defaultSettings, ...defaultSettings,
location: isBrowser() ? window.location : undefined, location: isBrowser() ? window.location : undefined,
}; };
const mapStateToProps = state => ({
export default BasicLayout; flatMenu: state.getIn(['global', 'flatMenu']),
menu: state.getIn(['global', 'menu']),
recentKeywords: state.getIn(['global', 'recentKeywords']),
recentVisited: state.getIn(['global', 'recentVisited']),
recentProducts: state.getIn(['global', 'recentProducts']),
});
const mapDispatchToProps = dispatch => ({
updateConfig(config) {
dispatch(actionCreators.getConfig(config));
},
createContext(data) {
dispatch(actionCreators.createContext(data));
},
updateLoginMode(mode) {
dispatch(actionCreators.changeLoginMode(mode));
},
updateCurrentIndex(index) {
dispatch(actionCreators.updateCurrentIndex(index));
},
});
export default connect(
mapStateToProps,
mapDispatchToProps,
)(withRouter(BasicLayout));
\ No newline at end of file
...@@ -250,7 +250,7 @@ ...@@ -250,7 +250,7 @@
margin-bottom: 0!important; margin-bottom: 0!important;
.test-icon{ .test-icon{
margin-left: 20px; margin-left: 20px;
padding-left: 20px!important; padding:0 10px!important;
} }
.@{ant-prefix}-menu-title-content{ .@{ant-prefix}-menu-title-content{
...@@ -293,13 +293,12 @@ ...@@ -293,13 +293,12 @@
} }
.test-icon{ .test-icon{
margin-left: 20px; margin-left: 20px;
padding-left: 20px!important; padding:10px 0!important;
} }
} }
} }
} }
.test-icon { .test-icon {
width: 100%;
overflow: hidden; overflow: hidden;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
...@@ -335,12 +334,11 @@ ...@@ -335,12 +334,11 @@
} }
} }
.my-desc { .my-desc {
margin-left: 4px; margin-left: 2px;
color: #7c7c7a; color: #7c7c7a;
} }
} }
.test-icon:hover{ .test-icon:hover{
color: @hn-greenColor;
.my-desc { .my-desc {
color: @hn-greenColor; color: @hn-greenColor;
} }
...@@ -352,7 +350,6 @@ ...@@ -352,7 +350,6 @@
} }
} }
.hight-active:hover{ .hight-active:hover{
color: #fff;
.my-desc { .my-desc {
color: #fff; color: #fff;
} }
...@@ -378,10 +375,14 @@ ...@@ -378,10 +375,14 @@
text-overflow: ellipsis; text-overflow: ellipsis;
vertical-align: bottom; vertical-align: bottom;
} }
.@{ant-prefix}-menu-submenu-title{
padding-right: 14px!important;
}
.ant-menu-submenu-title{
padding-right: 14px!important;
}
.hight-active { .hight-active {
color: #fff;
background: @hn-greenColor; background: @hn-greenColor;
// background: #00b278;
border-radius: 5px; border-radius: 5px;
.my-desc { .my-desc {
color: #fff; color: #fff;
......
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