UnisKB/ui/src/layout/components/sidebar/index.vue

45 lines
985 B
Vue
Raw Normal View History

2023-10-16 10:58:51 +00:00
<template>
<div class="sidebar">
<el-scrollbar wrap-class="scrollbar-wrapper">
2023-11-07 07:30:15 +00:00
<el-menu :default-active="activeMenu" router>
2023-10-16 10:58:51 +00:00
<sidebar-item
v-hasPermission="menu.meta?.permission"
v-for="(menu, index) in subMenuList"
:key="index"
2023-11-07 07:30:15 +00:00
:menu="menu"
2023-10-16 10:58:51 +00:00
>
</sidebar-item>
</el-menu>
</el-scrollbar>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import { getChildRouteListByPathAndName } from '@/router/index'
import SidebarItem from './SidebarItem.vue'
const route = useRoute()
2023-11-07 07:30:15 +00:00
2023-10-16 10:58:51 +00:00
const subMenuList = computed(() => {
2023-11-07 11:04:59 +00:00
const { meta } = route
return getChildRouteListByPathAndName(meta.parentPath, meta.parentName)
2023-10-16 10:58:51 +00:00
})
const activeMenu = computed(() => {
2023-11-07 07:30:15 +00:00
const { path, meta } = route
return meta.active || path
2023-10-16 10:58:51 +00:00
})
</script>
<style lang="scss">
.sidebar {
2023-11-02 10:25:09 +00:00
padding: 8px;
2023-10-16 10:58:51 +00:00
.el-menu {
height: 100%;
border: none;
}
}
</style>