style: simplify sidebar css

This commit is contained in:
pany 2024-02-28 17:04:25 +08:00
parent d8ab55fe2a
commit c6225b3cf7
2 changed files with 25 additions and 47 deletions

View File

@ -7,16 +7,12 @@ import path from "path-browserify"
interface Props { interface Props {
item: RouteRecordRaw item: RouteRecordRaw
isCollapse?: boolean
isTop?: boolean isTop?: boolean
isFirstLevel?: boolean
basePath?: string basePath?: string
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
isCollapse: false,
isTop: false, isTop: false,
isFirstLevel: true,
basePath: "" basePath: ""
}) })
@ -60,7 +56,6 @@ const resolvePath = (routePath: string) => {
</script> </script>
<template> <template>
<div :class="{ 'simple-mode': props.isCollapse && !isTop, 'first-level': props.isFirstLevel }">
<template v-if="!alwaysShowRootMenu && theOnlyOneChild && !theOnlyOneChild.children"> <template v-if="!alwaysShowRootMenu && theOnlyOneChild && !theOnlyOneChild.children">
<SidebarItemLink v-if="theOnlyOneChild.meta" :to="resolvePath(theOnlyOneChild.path)"> <SidebarItemLink v-if="theOnlyOneChild.meta" :to="resolvePath(theOnlyOneChild.path)">
<el-menu-item :index="resolvePath(theOnlyOneChild.path)"> <el-menu-item :index="resolvePath(theOnlyOneChild.path)">
@ -83,13 +78,10 @@ const resolvePath = (routePath: string) => {
v-for="child in showingChildren" v-for="child in showingChildren"
:key="child.path" :key="child.path"
:item="child" :item="child"
:is-collapse="props.isCollapse"
:is-first-level="false"
:base-path="resolvePath(child.path)" :base-path="resolvePath(child.path)"
/> />
</template> </template>
</el-sub-menu> </el-sub-menu>
</div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -104,17 +96,4 @@ const resolvePath = (routePath: string) => {
margin-right: 12px; margin-right: 12px;
font-size: 18px; font-size: 18px;
} }
.simple-mode {
&.first-level {
:deep(.el-sub-menu) {
.el-sub-menu__icon-arrow {
display: none;
}
span {
visibility: hidden;
}
}
}
}
</style> </style>

View File

@ -68,7 +68,6 @@ const hiddenScrollbarVerticalBar = computed(() => {
:key="route.path" :key="route.path"
:item="route" :item="route"
:base-path="route.path" :base-path="route.path"
:is-collapse="isCollapse"
:is-top="isTop" :is-top="isTop"
/> />
</el-menu> </el-menu>