添加后台管理框架雏形
This commit is contained in:
236
frontend/src/components/sidebar.vue
Normal file
236
frontend/src/components/sidebar.vue
Normal file
@@ -0,0 +1,236 @@
|
||||
<template>
|
||||
<div class="sidebar">
|
||||
<el-menu class="sidebar-el-menu" :default-active="onRoutes" :collapse="sidebar.collapse" background-color="#324157"
|
||||
text-color="#bfcbd9" active-text-color="#20a0ff" unique-opened 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>
|
||||
<template v-for="subItem in item.subs">
|
||||
<el-sub-menu v-if="subItem.subs" :index="subItem.index" :key="subItem.index"
|
||||
v-permiss="item.permiss">
|
||||
<template #title>{{ subItem.title }}</template>
|
||||
<el-menu-item v-for="(threeItem, i) in subItem.subs" :key="i" :index="threeItem.index">
|
||||
{{ threeItem.title }}
|
||||
</el-menu-item>
|
||||
</el-sub-menu>
|
||||
<el-menu-item v-else :index="subItem.index" v-permiss="item.permiss">
|
||||
{{ subItem.title }}
|
||||
</el-menu-item>
|
||||
</template>
|
||||
</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 { 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: 'Monitor',
|
||||
index: '/monitor-data',
|
||||
title: '监测数据',
|
||||
permiss: 'monitor-data',
|
||||
subs: [
|
||||
{
|
||||
index: '/monitor-data-view',
|
||||
title: '查看数据',
|
||||
permiss: 'monitor-data-view',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
icon: 'BellFilled',
|
||||
index: '/warning',
|
||||
title: '预警信息',
|
||||
permiss: 'warning',
|
||||
subs: [
|
||||
{
|
||||
index: '/warning-view',
|
||||
title: '总览',
|
||||
permiss: 'warning-view',
|
||||
},
|
||||
{
|
||||
index: '/warning-setting',
|
||||
title: '预警设置',
|
||||
permiss: 'warning-setting',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
icon: 'OfficeBuilding',
|
||||
index: '/equipment',
|
||||
title: '设备信息',
|
||||
permiss: 'equipment',
|
||||
subs: [
|
||||
{
|
||||
index: '/equipment-setting',
|
||||
title: '设备管理',
|
||||
permiss: 'equipment-setting',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
icon: 'Avatar',
|
||||
index: '/privilege',
|
||||
title: '用户角色',
|
||||
permiss: 'privilege',
|
||||
subs: [
|
||||
{
|
||||
index: '/privilege-user-setting',
|
||||
title: '用户管理', // 列表 增删改
|
||||
permiss: 'privilege-user-setting',
|
||||
},
|
||||
{
|
||||
index: '/privilege-role-setting',
|
||||
title: '角色权限', // 列表 增删改<角色名;角色对应权限>
|
||||
permiss: 'privilege-role-setting',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
... !settings.debugMode ? [] : [
|
||||
{
|
||||
icon: 'Odometer',
|
||||
index: '/',
|
||||
title: '——————————',
|
||||
permiss: 'default',
|
||||
},
|
||||
{
|
||||
icon: 'Calendar',
|
||||
index: '1',
|
||||
title: '表格相关',
|
||||
permiss: 'default',
|
||||
subs: [
|
||||
{
|
||||
index: '/table',
|
||||
title: '常用表格',
|
||||
permiss: 'default',
|
||||
},
|
||||
{
|
||||
index: '/import',
|
||||
title: '导入Excel',
|
||||
permiss: 'default',
|
||||
},
|
||||
{
|
||||
index: '/export',
|
||||
title: '导出Excel',
|
||||
permiss: 'default',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
icon: 'DocumentCopy',
|
||||
index: '/tabs',
|
||||
title: 'tab选项卡',
|
||||
permiss: 'default',
|
||||
},
|
||||
{
|
||||
icon: 'Edit',
|
||||
index: '3',
|
||||
title: '表单相关',
|
||||
permiss: 'default',
|
||||
subs: [
|
||||
{
|
||||
index: '/form',
|
||||
title: '基本表单',
|
||||
permiss: 'default',
|
||||
},
|
||||
{
|
||||
index: '/upload',
|
||||
title: '文件上传',
|
||||
permiss: 'default',
|
||||
},
|
||||
{
|
||||
index: '4',
|
||||
title: '三级菜单',
|
||||
permiss: 'default',
|
||||
subs: [
|
||||
{
|
||||
index: '/editor',
|
||||
title: '富文本编辑器',
|
||||
permiss: 'default',
|
||||
},
|
||||
{
|
||||
index: '/markdown',
|
||||
title: 'markdown编辑器',
|
||||
permiss: '9default',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
icon: 'Setting',
|
||||
index: '/icon',
|
||||
title: '自定义图标',
|
||||
permiss: 'default',
|
||||
},
|
||||
{
|
||||
icon: 'PieChart',
|
||||
index: '/charts',
|
||||
title: 'schart图表',
|
||||
permiss: 'default',
|
||||
},
|
||||
]
|
||||
];
|
||||
|
||||
const route = useRoute();
|
||||
const onRoutes = computed(() => {
|
||||
return route.path;
|
||||
});
|
||||
|
||||
const sidebar = useSidebarStore();
|
||||
</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>
|
Reference in New Issue
Block a user