feat : 修改菜单状态

This commit is contained in:
clay
2024-05-23 14:49:56 +08:00
parent 21f90e438c
commit e9e5a0c785
9 changed files with 36 additions and 21 deletions

View File

@@ -12,13 +12,13 @@
</template>
<script setup>
import { useRoute, useRouter } from 'vue-router';
import {useRoute, useRouter} from 'vue-router';
const route = useRoute()
const router = useRouter()
watch(route, ()=> {
watch(route, () => {
getBreadcrumb()
})
@@ -29,7 +29,7 @@ const breadcrumbList = ref([])
const getBreadcrumb = () => {
let matched = route.matched.filter(item => item.meta && item.meta.title)
const first = matched[0]
if(!isDashboard(first)) {
if (!isDashboard(first)) {
matched = [{path: '/home', meta: {title: '首页'}}].concat(matched)
}
breadcrumbList.value.length = 0;
@@ -39,7 +39,7 @@ const getBreadcrumb = () => {
const isDashboard = (meta) => {
const name = meta && meta.name
if(!name) {
if (!name) {
return
}
return name.trim().toLocaleLowerCase() === 'Home'.toLocaleLowerCase()

View File

@@ -1,7 +1,7 @@
<template>
<!-- 有子菜单 -->
<template v-for="item in menuItem" :key="item.path">
<el-sub-menu v-if="item?.children?.length>0 && !item.hidden" :index="item.path">
<el-sub-menu v-if="checkMenuItem(item)" :index="item.path">
<template #title>
<svg-icon :name="item.icon"/>
<span>{{ item.title }}</span>
@@ -44,5 +44,19 @@ const handleGo = (path) => {
}
}
const checkMenuItem = (item) => {
let children = item.children
let childState = false;
if (children){
for (let child of children) {
if (!child.hidden) {
childState = true
break
}
}
}
return item?.children?.length>0 && !item.hidden && childState
}
</script>

View File

@@ -1,6 +1,7 @@
<template>
<div class="logo" ref="logo">
<span v-if="!siderbarStore.isCollapse">科研管理平台</span>
<!-- <span v-if="!siderbarStore.isCollapse">科研管理平台</span>-->
<span v-if="!siderbarStore.isCollapse"></span>
</div>
<el-scrollbar :height="`calc(100vh - ${logoHeight}px)`" style="background-color: #ffffff">
<el-menu