优化路由

This commit is contained in:
wangsongsole 2022-08-18 09:51:52 +08:00
parent 34911c5d66
commit a583b23e03
2 changed files with 15 additions and 12 deletions

View File

@ -6,7 +6,7 @@ import Bus from '@/assets/eventBus.js'
import Subnav from '@/components/subnav/main' import Subnav from '@/components/subnav/main'
import { Avatar, Pop, Sweetalert, Dialog, Icon, Notify } from 'zent' import { Avatar, Pop, Sweetalert, Dialog, Icon, Notify } from 'zent'
import ModifySelfpwd from './ModifySelfpwd' import ModifySelfpwd from './ModifySelfpwd'
import { router, navRoute } from '@/router/index' import { router, navRoute, noShowSubMenu } from '@/router/index'
import { import {
getUserinfo, getUserinfo,
@ -24,13 +24,6 @@ export default class App extends Component {
setrender: 1, setrender: 1,
linkshow: '系统管理', linkshow: '系统管理',
isShowSub: true, isShowSub: true,
noShowSubMenu: [
'/home/extension',
'/home/overview',
'/home/plan-create',
'/home/mytempMould',
'/home/edittemplate'
],
pathname: '', pathname: '',
userInfo: {}, userInfo: {},
navlist: navRoute navlist: navRoute
@ -44,7 +37,7 @@ export default class App extends Component {
Bus.addListener('closeMask', (prop) => { Bus.addListener('closeMask', (prop) => {
this.setState({ mouseMenuMask: prop }) this.setState({ mouseMenuMask: prop })
}) })
if (this.state.noShowSubMenu.indexOf(this.props.location.pathname) > -1) { if (noShowSubMenu.indexOf(this.props.location.pathname) > -1) {
this.setState({ isShowSub: false }) this.setState({ isShowSub: false })
} else { } else {
this.setState({ isShowSub: true }) this.setState({ isShowSub: true })
@ -133,7 +126,7 @@ export default class App extends Component {
} }
} }
if (this.state.noShowSubMenu.indexOf(nextProps.location.pathname) > -1) { if (noShowSubMenu.indexOf(nextProps.location.pathname) > -1) {
this.setState({ isShowSub: false }) this.setState({ isShowSub: false })
} else { } else {
this.setState({ isShowSub: true }) this.setState({ isShowSub: true })

View File

@ -46,7 +46,7 @@ import DistriButorEdit from '@/pages/distributor/add/add'
import MyTempMouldAdd from '@/pages/exchangepage/template/main.js' import MyTempMouldAdd from '@/pages/exchangepage/template/main.js'
import MyExChangeTemplate from '@/pages/exchangepage/mytemplate/main.js' import MyExChangeTemplate from '@/pages/exchangepage/mytemplate/main.js'
import CopyCode from '@/pages/exchangecode/copyCode/index' import CopyCode from '@/pages/exchangecode/copyCode/index'
/* 基础路由 */
const router = [ const router = [
{ {
path: '/home/extension', path: '/home/extension',
@ -250,6 +250,7 @@ const router = [
} }
] ]
/* 导航现实路由 */
const navRoute = [ const navRoute = [
{ {
name: '系统管理', name: '系统管理',
@ -326,4 +327,13 @@ const navRoute = [
} }
] ]
export { router, navRoute } /* 不显示路由 */
const noShowSubMenu = [
'/home/extension',
'/home/overview',
'/home/plan-create',
'/home/mytempMould',
'/home/edittemplate'
]
export { router, navRoute, noShowSubMenu }