mt-ck-wms-ui/src/layout/components/Sidebar/index.vue
2021-12-22 16:13:55 +08:00

68 lines
1.8 KiB
Vue

<!--
* @Author: your name
* @Date: 2021-01-27 10:07:42
* @LastEditTime: 2021-12-22 16:06:25
* @LastEditors: zwq
* @Description: In User Settings Edit
* @FilePath: \mt-bus-fe\src\layout\components\Sidebar\index.vue
-->
<template>
<div :class="{'has-logo':showLogo}">
<logo v-if="showLogo" :font-size="language === 'en' ? '16px' : '12px'" :title="'title' | i18nFilter" :collapse="isCollapse" />
<el-scrollbar wrap-class="scrollbar-wrapper">
<el-menu
:default-active="activeMenu"
:collapse="isCollapse"
:background-color="variables.menuBg"
:text-color="variables.menuText"
:unique-opened="false"
:active-text-color="variables.menuActiveText"
:collapse-transition="false"
mode="vertical"
>
<sidebar-item v-for="route in routeList" :key="route.path" :item="route" :base-path="route.path" />
</el-menu>
</el-scrollbar>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
import Logo from './Logo'
import SidebarItem from './SidebarItem'
import variables from '@/styles/variables.scss'
import { constantRoutes } from '@/router'
export default {
components: { SidebarItem, Logo },
computed: {
...mapGetters([
'sidebar',
'permission_routes',
'language'
]),
routeList() {
return constantRoutes
},
activeMenu() {
const route = this.$route
const { meta, path } = route
// if set path, the sidebar will highlight the path you set
if (meta.activeMenu) {
return meta.activeMenu
}
return path
},
showLogo() {
console.log(this.$route)
return this.$store.state.settings.sidebarLogo
},
variables() {
return variables
},
isCollapse() {
return !this.sidebar.opened
}
}
}
</script>