From 7c17278cd88c5408493febfb69285088e181e47c Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Fri, 26 Jan 2024 16:25:40 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AA=20optimize:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=9D=A2=E5=8C=85=E5=B1=91=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/subnav/main.js | 84 +++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 39 deletions(-) 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" : ""