mirror of
https://github.com/un-pany/v3-admin-vite.git
synced 2025-04-20 19:09:21 +08:00
style: simplify sidebar css
This commit is contained in:
parent
d8ab55fe2a
commit
c6225b3cf7
@ -7,16 +7,12 @@ import path from "path-browserify"
|
||||
|
||||
interface Props {
|
||||
item: RouteRecordRaw
|
||||
isCollapse?: boolean
|
||||
isTop?: boolean
|
||||
isFirstLevel?: boolean
|
||||
basePath?: string
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
isCollapse: false,
|
||||
isTop: false,
|
||||
isFirstLevel: true,
|
||||
basePath: ""
|
||||
})
|
||||
|
||||
@ -60,36 +56,32 @@ const resolvePath = (routePath: string) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div :class="{ 'simple-mode': props.isCollapse && !isTop, 'first-level': props.isFirstLevel }">
|
||||
<template v-if="!alwaysShowRootMenu && theOnlyOneChild && !theOnlyOneChild.children">
|
||||
<SidebarItemLink v-if="theOnlyOneChild.meta" :to="resolvePath(theOnlyOneChild.path)">
|
||||
<el-menu-item :index="resolvePath(theOnlyOneChild.path)">
|
||||
<SvgIcon v-if="theOnlyOneChild.meta.svgIcon" :name="theOnlyOneChild.meta.svgIcon" />
|
||||
<component v-else-if="theOnlyOneChild.meta.elIcon" :is="theOnlyOneChild.meta.elIcon" class="el-icon" />
|
||||
<template v-if="theOnlyOneChild.meta.title" #title>
|
||||
{{ theOnlyOneChild.meta.title }}
|
||||
</template>
|
||||
</el-menu-item>
|
||||
</SidebarItemLink>
|
||||
<template v-if="!alwaysShowRootMenu && theOnlyOneChild && !theOnlyOneChild.children">
|
||||
<SidebarItemLink v-if="theOnlyOneChild.meta" :to="resolvePath(theOnlyOneChild.path)">
|
||||
<el-menu-item :index="resolvePath(theOnlyOneChild.path)">
|
||||
<SvgIcon v-if="theOnlyOneChild.meta.svgIcon" :name="theOnlyOneChild.meta.svgIcon" />
|
||||
<component v-else-if="theOnlyOneChild.meta.elIcon" :is="theOnlyOneChild.meta.elIcon" class="el-icon" />
|
||||
<template v-if="theOnlyOneChild.meta.title" #title>
|
||||
{{ theOnlyOneChild.meta.title }}
|
||||
</template>
|
||||
</el-menu-item>
|
||||
</SidebarItemLink>
|
||||
</template>
|
||||
<el-sub-menu v-else :index="resolvePath(props.item.path)" teleported>
|
||||
<template #title>
|
||||
<SvgIcon v-if="props.item.meta?.svgIcon" :name="props.item.meta.svgIcon" />
|
||||
<component v-else-if="props.item.meta?.elIcon" :is="props.item.meta.elIcon" class="el-icon" />
|
||||
<span v-if="props.item.meta?.title">{{ props.item.meta.title }}</span>
|
||||
</template>
|
||||
<el-sub-menu v-else :index="resolvePath(props.item.path)" teleported>
|
||||
<template #title>
|
||||
<SvgIcon v-if="props.item.meta?.svgIcon" :name="props.item.meta.svgIcon" />
|
||||
<component v-else-if="props.item.meta?.elIcon" :is="props.item.meta.elIcon" class="el-icon" />
|
||||
<span v-if="props.item.meta?.title">{{ props.item.meta.title }}</span>
|
||||
</template>
|
||||
<template v-if="props.item.children">
|
||||
<SidebarItem
|
||||
v-for="child in showingChildren"
|
||||
:key="child.path"
|
||||
:item="child"
|
||||
:is-collapse="props.isCollapse"
|
||||
:is-first-level="false"
|
||||
:base-path="resolvePath(child.path)"
|
||||
/>
|
||||
</template>
|
||||
</el-sub-menu>
|
||||
</div>
|
||||
<template v-if="props.item.children">
|
||||
<SidebarItem
|
||||
v-for="child in showingChildren"
|
||||
:key="child.path"
|
||||
:item="child"
|
||||
:base-path="resolvePath(child.path)"
|
||||
/>
|
||||
</template>
|
||||
</el-sub-menu>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@ -104,17 +96,4 @@ const resolvePath = (routePath: string) => {
|
||||
margin-right: 12px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.simple-mode {
|
||||
&.first-level {
|
||||
:deep(.el-sub-menu) {
|
||||
.el-sub-menu__icon-arrow {
|
||||
display: none;
|
||||
}
|
||||
span {
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -68,7 +68,6 @@ const hiddenScrollbarVerticalBar = computed(() => {
|
||||
:key="route.path"
|
||||
:item="route"
|
||||
:base-path="route.path"
|
||||
:is-collapse="isCollapse"
|
||||
:is-top="isTop"
|
||||
/>
|
||||
</el-menu>
|
||||
|
Loading…
x
Reference in New Issue
Block a user