💪 optimize: 优化面包屑代码

This commit is contained in:
wangsongsole 2024-01-26 16:25:40 +08:00
parent 2034bb4525
commit 7c17278cd8
1 changed files with 45 additions and 39 deletions

View File

@ -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"
: ""