Commit 28a2affc authored by 崔佳豪's avatar 崔佳豪

fix: 菜单报错修改

parent 7eed81cf
...@@ -135,20 +135,21 @@ const CommonMenu = props => { ...@@ -135,20 +135,21 @@ const CommonMenu = props => {
* @param {*} menu * @param {*} menu
*/ */
const linkToMenu = menu => { const linkToMenu = menu => {
console.log("props", props) const { name, path, topGroup } = menu;
const { path, topGroup } = menu;
const currentIndex = props.menus.findIndex(item => item.name === topGroup); const currentIndex = props.menus.findIndex(item => item.name === topGroup);
let currentRoutes = props.flatMenu.find(item => item.path === path && item.name === name);
// let currentRoutes = props.menus[currentIndex] && props.menus[currentIndex].routes;
// currentRoutes = currentRoutes.find(item => item.path === path);
if(currentRoutes) {
history.push(path); history.push(path);
props.updateCurrentIndex(currentIndex); props.updateCurrentIndex(currentIndex);
let currentRoutes = props.menus[currentIndex] && props.menus[currentIndex].routes;
currentRoutes = currentRoutes.find(item => item.path === path);
window.share && window.share.event.emit('trigger:updateMenuIndex', currentIndex); window.share && window.share.event.emit('trigger:updateMenuIndex', currentIndex);
window.share && window.share.event && window.share.event.emit('event:updateCurrentChildrenRoutes', { window.share && window.share.event && window.share.event.emit('event:updateCurrentChildrenRoutes', {
currentPath: path, currentPath: path,
currentRoute: currentRoutes, currentRoute: currentRoutes,
selectedIndex: currentIndex selectedIndex: currentIndex
}); });
}
}; };
const mdOk = submitData => { const mdOk = submitData => {
...@@ -433,21 +434,30 @@ const MenuAddModal = props => { ...@@ -433,21 +434,30 @@ const MenuAddModal = props => {
<div className={styles.menuWrapper} key={item.key}> <div className={styles.menuWrapper} key={item.key}>
<p className={styles.menuGroupTitle}>{item.name}</p> <p className={styles.menuGroupTitle}>{item.name}</p>
<div className={styles.menuList}> <div className={styles.menuList}>
{item.childMenus.map(child => { {Array.isArray(item.childMenus) &&
item.childMenus.map(child => {
const { match, name } = child; const { match, name } = child;
const [before, after] = match;
const { isAdded } = child.extData; const { isAdded } = child.extData;
const bname = after > -1 ? name.slice(0, before) : ''; let bname = '',
const cname = cname = '',
aname = name;
if (match) {
const [before, after] = match;
bname = after > -1 ? name.slice(0, before) : '';
cname =
after > -1 ? ( after > -1 ? (
<em style={{ color: 'orange', fontStyle: 'normal' }}> <em style={{ color: 'orange', fontStyle: 'normal' }}>
                            
{name.slice(before, after + 1)} {name.slice(before, after + 1)}
                          
</em> </em>
) : ( ) : (
'' ''
); );
const aname = aname =
after > -1 ? name.slice(after + 1, name.length) : name; after > -1 ? name.slice(after + 1, name.length) : name;
}
return ( return (
<div <div
key={child.key} key={child.key}
...@@ -487,11 +497,12 @@ const MenuAddModal = props => { ...@@ -487,11 +497,12 @@ const MenuAddModal = props => {
const mapStateToProps = state => ({ const mapStateToProps = state => ({
menus: state.getIn(['global', 'menu']), menus: state.getIn(['global', 'menu']),
flatMenu: state.getIn(['global', 'flatMenu']),
}); });
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
updateCurrentIndex(index) { updateCurrentIndex(index) {
dispatch(actionCreators.updateCurrentIndex(index)); dispatch(actionCreators.updateCurrentIndex(index));
} },
}); });
export default connect( export default connect(
mapStateToProps, mapStateToProps,
......
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