You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
frontend/src/components/common/Sidebar.vue

180 lines
4.3 KiB
Vue

2 years ago
<template>
<div class="sidebar">
<el-menu
2 years ago
:default-active="activeIndex"
class="sidebar-el-menu"
mode="horizontal"
router
>
<template v-for="item in items">
<template v-if="item.subs">
<el-submenu :index="item.index" :key="item.index">
<template slot="title">
<i :class="item.icon"></i>
<span slot="title">{{ item.title }}</span>
2 years ago
</template>
<template v-for="subItem in item.subs">
<el-submenu
v-if="subItem.subs"
:index="subItem.index"
:key="subItem.index"
>
<template slot="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-submenu>
<el-menu-item
v-else
:index="subItem.index"
:key="subItem.index"
>{{ subItem.title }}</el-menu-item
>
</template>
</el-submenu>
</template>
<template v-else>
<el-menu-item :index="item.index" :key="item.index">
<i :class="item.icon"></i>
<span slot="title">{{ item.title }}</span>
</el-menu-item>
</template>
</template>
</el-menu>
</div>
2 years ago
</template>
<script>
export default {
data() {
return {
2 years ago
activeIndex: "/realTimeMonitor",
items: [
2 years ago
// {
// icon: "el-icon-s-home",
// index: "stritl",
// title: "首页",
// },
{
icon: "el-icon-camera",
2 years ago
index: "/realTimeMonitor",
title: "实时监控",
},
2 years ago
2 years ago
{
2 years ago
icon: "el-icon-film",
2 years ago
index: "/pictureRotation",
2 years ago
title: "图片轮巡",
2 years ago
},
2 years ago
// {
// icon: "el-icon-bell",
// index: "photoAlarm",
// title: "告警处理",
// },
2 years ago
2 years ago
{
2 years ago
icon: "el-icon-search",
2 years ago
index: "/realTimeSearch",
2 years ago
title: "实时查询",
2 years ago
},
{
icon: "el-icon-files",
2 years ago
index: "/property",
title: "资产管理",
subs: [
{
2 years ago
index: "/lineInformation",
2 years ago
title: "线路信息管理",
},
{
2 years ago
index: "/towerInformation",
2 years ago
title: "杆塔信息管理",
},
{
2 years ago
index: "/cameraChannel",
2 years ago
title: "通道管理",
},
2 years ago
{
index: "/photographicDevice",
title: "拍照装置管理",
},
2 years ago
{
icon: "el-icon-setting",
2 years ago
index: "/devicePhotoSchedule",
2 years ago
title: "拍照时间表设置",
},
2 years ago
// {
// icon: "el-icon-picture-outline",
// index: "imageSettings",
// title: "图像采集参数设置",
// },
2 years ago
],
},
2 years ago
// {
// icon: "el-icon-monitor",
// index: "/system",
// title: "系统管理",
// subs: [
// {
// index: "/userManagement",
// title: "用户管理",
// },
// ],
// },
],
};
},
2 years ago
watch: {
2 years ago
$route() {
this.setCurrentRoute();
2 years ago
},
},
2 years ago
methods: {
2 years ago
setCurrentRoute() {
this.activeIndex = this.$route.path; // 通过他就可以监听到当前路由状态并激活当前菜单
2 years ago
},
},
2 years ago
created() {
this.setCurrentRoute();
},
2 years ago
};
</script>
<style lang="less">
.sidebar {
float: left;
.el-menu--horizontal {
.el-menu-item {
height: 70px;
line-height: 70px;
}
.el-submenu .el-submenu__title {
height: 70px;
line-height: 70px;
}
.el-dropdown-menu__item,
.el-menu-item,
.el-submenu__title {
font-size: 16px;
}
.el-menu-item i {
color: @color-text-secondary;
}
.el-menu-item.is-active {
i {
color: @color-primary;
}
}
.el-submenu.is-active .el-submenu__title > i {
&:first-child {
color: @color-primary;
}
2 years ago
}
}
2 years ago
}
</style>