diff --git a/src/components/subnav/main.js b/src/components/subnav/main.js index be0b735a..7848a392 100644 --- a/src/components/subnav/main.js +++ b/src/components/subnav/main.js @@ -1,9 +1,9 @@ import React from "react" -import "./main.less" -import { Pop } from "zent" -import MouseMenu from "../mouseMenu/main.js" -import Bus from "../../assets/eventBus.js" import { Link } from "react-router-dom" +import { Pop } from "zent" +import Bus from "../../assets/eventBus.js" +import MouseMenu from "../mouseMenu/main.js" +import "./main.less" export default class topNav extends React.Component { constructor(props) { super(props) @@ -86,43 +86,49 @@ export default class topNav extends React.Component { let breaknav = JSON.parse(sessionStorage.getItem("breaknav")) let urlHref = window.location.href.replace(/^\/|\/$/g, "") const pathname = urlHref.lastIndexOf("/") - const pathnamestr = urlHref.substr(pathname) - let breakflag = - pathnamestr.includes("add") || - pathnamestr.includes("aid") || - pathnamestr.includes("exchangecode-exchangecodeAdd") || - pathnamestr.includes("distributor-edit") || - pathnamestr.includes("key-list") || - pathnamestr.includes("key-detail") || - pathnamestr.includes("key-edit") || - pathnamestr.includes("key-addEdit") || - pathnamestr.includes("plan-edit") || - pathnamestr.includes("product-edit") || - pathnamestr.includes("distributor-merchant") || - pathnamestr.includes("callback-message") || - pathnamestr.includes("coupon-commodity") - let sedcbreakflag = pathnamestr.includes("plan-create") - let planbreakflag = pathnamestr.includes("mytempMould") - let editbreakflag = pathnamestr.includes("edittemplate") - let backshow = - pathnamestr.includes("account-add") || - pathnamestr.includes("role-add") || - pathnamestr.includes("distributor-add") || - pathnamestr.includes("subaccount-add") || - pathnamestr.includes("plan-edit") || - pathnamestr.includes("key-list") || - pathnamestr.includes("exchange-addcommodity") - let breakchange = - pathnamestr.includes("exchangecode-add") || - pathnamestr.includes("key-edit") || - pathnamestr.includes("key-addEdit") || - pathnamestr.includes("key-detail") || - pathnamestr.includes("product-edit") || - pathnamestr.includes("plan-edit") + const pathNameString = urlHref.substr(pathname) + const breakFlagRoutes = [ + "add", + "aid", + "exchangecode-exchangecodeAdd", + "distributor-edit", + "key-list", + "key-detail", + "key-edit", + "key-addEdit", + "plan-edit", + "product-edit", + "distributor-merchant", + "callback-message", + "coupon-commodity" + ] + const backShowRoutes = [ + "account-add", + "role-add", + "distributor-add", + "subaccount-add", + "plan-edit", + "key-list", + "exchange-addcommodity" + ] + const breakChangeRoutes = [ + "exchangecode-add", + "key-edit", + "key-addEdit", + "key-detail", + "product-edit", + "plan-edit" + ] + let breakflag = breakFlagRoutes.some((keyword) => pathNameString.includes(keyword)) + let backshow = backShowRoutes.some((keyword) => pathNameString.includes(keyword)) + let breakchange = breakChangeRoutes.some((keyword) => pathNameString.includes(keyword)) + let sedcbreakflag = pathNameString.includes("plan-create") + let planbreakflag = pathNameString.includes("mytempMould") + let editbreakflag = pathNameString.includes("edittemplate") if (breakchange) { breaknav = JSON.parse(sessionStorage.getItem("breakchangenav")) } - if (pathnamestr.includes("aid")) { + if (pathNameString.includes("aid")) { breaknav = JSON.parse(sessionStorage.getItem("subbreaknav")) } let accPath = null @@ -186,7 +192,7 @@ export default class topNav extends React.Component { to={item.router} onClick={() => this.btnfn(item)} className={ - item.router.includes(pathnamestr) && + item.router.includes(pathNameString) && this.state.menulinklist.filter((it) => it.level == 5).length > 1 ? "menuactive" : ""