1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
Files
epp/frontend/src/components/sidebar.vue

149 lines
4.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="sidebar">
<el-menu class="sidebar-el-menu" :default-active="onRoutes" :collapse="sidebar.collapse"
:default-openeds="activeItemList" background-color="#324157" text-color="#bfcbd9" active-text-color="#20a0ff"
router>
<template v-for="item in items">
<template v-if="item.subs">
<el-sub-menu :index="item.index" :key="item.index" v-permiss="item.permiss">
<template #title>
<el-icon>
<component :is="item.icon"></component>
</el-icon>
<span>{{ item.title }}</span>
</template>
<el-menu-item v-for="subItem in item.subs" :index="subItem.index" v-permiss="item.permiss">
{{ subItem.title }}
</el-menu-item>
</el-sub-menu>
</template>
<template v-else>
<el-menu-item :index="item.index" :key="item.index" v-permiss="item.permiss">
<el-icon>
<component :is="item.icon"></component>
</el-icon>
<template #title>{{ item.title }}</template>
</el-menu-item>
</template>
</template>
</el-menu>
</div>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue';
import { useSidebarStore } from '../store/sidebar';
import { useRoute } from 'vue-router';
import settings from '../utils/settings';
const items = [
// 图标见https://element-plus.gitee.io/zh-CN/component/icon.html
{
icon: 'HomeFilled',//'/assets/image/svg/alert_warning.svg',
index: '/dashboard',
title: '系统首页', // 站点基础信息
permiss: 'dashboard',
},
{
icon: 'OfficeBuilding',
index: '/access',
title: '人员进出',
permiss: 'access',
subs: [
{
index: '/access-log',
title: '人员进出记录',
permiss: 'access-log',
},
{
index: '/access-gate-setting',
title: '大门管理',
permiss: 'access-gate-setting',
},
],
},
{
icon: 'OfficeBuilding',
index: '/report',
title: '体温上报',
permiss: 'report',
subs: [
{
index: '/report-log',
title: '体温上报记录',
permiss: 'report-log',
},
],
},
{
icon: 'OfficeBuilding',
index: '/shop',
title: '生活物资',
permiss: 'shop',
subs: [
{
index: '/shop-cate-setting',
title: '分类管理',
permiss: 'shop-cate-setting',
},
{
index: '/shop-good-setting',
title: '商品管理',
permiss: 'shop-good-setting',
},
{
index: '/shop-order-setting',
title: '订单管理',
permiss: 'shop-order-setting',
},
],
},
{
icon: 'Avatar',
index: '/privilege',
title: '系统管理',
permiss: 'privilege',
subs: [
{
index: '/privilege-user-setting',
title: '用户管理',
permiss: 'privilege-user-setting',
},
],
},
];
const route = useRoute();
const onRoutes = computed(() => {
return route.path;
});
const sidebar = useSidebarStore();
// 默认全部展开
const activeItemList = items.map((i) => i.index)
</script>
<style scoped>
.sidebar {
display: block;
position: absolute;
left: 0;
top: 70px;
bottom: 0;
overflow-y: scroll;
}
.sidebar::-webkit-scrollbar {
width: 0;
}
.sidebar-el-menu:not(.el-menu--collapse) {
width: 200px;
}
.sidebar>ul {
min-height: 100%;
}
</style>