diff --git a/src/components/mouseMenu/main.js b/src/components/mouseMenu/main.js index 296dadd3..d851c562 100644 --- a/src/components/mouseMenu/main.js +++ b/src/components/mouseMenu/main.js @@ -1,72 +1,93 @@ -import React from "react" -import ReactDOM from "react-dom" -import "./main.less" -import { Icon } from "zent" -import { HashRouter as Router, Route, Link } from "react-router-dom"; -import Bus from "../../assets/eventBus.js"; +/* + * @Author: Wind + * @Date: 2022-08-17 12:09:24 + * @LastEditors: Wind + * @LastEditTime: 2022-08-17 15:55:08 + * @Description: + * @FilePath: \frontend\src\components\mouseMenu\main.js + */ +import React from 'react' +import ReactDOM from 'react-dom' +import './main.less' +import { Icon } from 'zent' +import { HashRouter as Router, Route, Link } from 'react-router-dom' +import Bus from '../../assets/eventBus.js' export default class MouseMenu extends React.Component { - constructor(props) { - super(props); - this.state = { - activeMenuList: []//总动态路由数据 + constructor(props) { + super(props) + this.state = { + activeMenuList: [] //总动态路由数据 + } + } + componentDidMount() { + let activeMenuList = JSON.parse(sessionStorage.getItem('activeMenu')) + this.setState({ activeMenuList }) + } + closeMenuMask() { + this.props.mouseLeaveFn() + } + //点击菜单 + clickMenuItem(e, it) { + if (it.router == '/home/distributor-add') { + sessionStorage.setItem('pathname2', '/home/system/distributor-add') + let activerou = [ + { + pagetitle: '新建', + items: [ + { + path: 'distributor-list', + name: '分销商管理' + }, + { + path: 'distributor-add', + name: '新建分销商' + } + ] } + ] + sessionStorage.setItem('breaknav', JSON.stringify(activerou)) } - componentDidMount() { - let activeMenuList = JSON.parse(sessionStorage.getItem("activeMenu")); - this.setState({ activeMenuList }); - } - closeMenuMask() { - this.props.mouseLeaveFn(); - } - //点击菜单 - clickMenuItem(e, it) { - if (it.router == '/home/distributor-add') { - sessionStorage.setItem('pathname2', '/home/system/distributor-add') - let activerou = [{ - 'pagetitle': '新建', items: [ - { - "path": "distributor-list", - "name": "分销商管理" - }, - { - "path": "distributor-add", - "name": "新建分销商" - } - ] - }] - sessionStorage.setItem('breaknav', JSON.stringify(activerou)); + this.props.mouseLeaveFn() + } + render() { + let menuList = this.state.activeMenuList //路由表 + let urlHref = window.location.href.replace(/^\/|\/$/g, '') + const pathname = urlHref.lastIndexOf('/') + const pathnamestr = urlHref.substr(pathname) - } - this.props.mouseLeaveFn(); - } - render() { - let menuList = this.state.activeMenuList;//路由表 - let urlHref=(window.location.href).replace(/^\/|\/$/g, ''); - const pathname = urlHref.lastIndexOf("/"); - const pathnamestr = urlHref.substr(pathname); - - return ( -