92 lines
2.2 KiB
Vue
92 lines
2.2 KiB
Vue
<!--
|
|
* @Description:
|
|
* @Author: zenghua.wang
|
|
* @Date: 2024-01-27 20:01:45
|
|
* @LastEditors: zenghua.wang
|
|
* @LastEditTime: 2024-03-30 14:32:07
|
|
-->
|
|
<template>
|
|
<div class="layout-sider" :class="{ 'has-logo': themeConfig.showLogo }">
|
|
<Logo v-if="themeConfig.showLogo" :is-collapse="isCollapse" />
|
|
<el-scrollbar wrap-class="layout-sider-scrollbar">
|
|
<el-menu
|
|
class="layout-sider-menu"
|
|
background-color="#fff"
|
|
text-color="#333"
|
|
active-text-color=""
|
|
:default-active="activeMenu"
|
|
:unique-opened="SettingStore.themeConfig.uniqueOpened"
|
|
:collapse-transition="false"
|
|
:collapse="isCollapse"
|
|
>
|
|
<SubItem v-for="item in permissionRoutes" :key="item.path" :item="item" />
|
|
</el-menu>
|
|
</el-scrollbar>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup name="layout-sider">
|
|
import { computed } from 'vue';
|
|
import { useRoute } from 'vue-router';
|
|
import Logo from '../Logo';
|
|
import SubItem from '../Menu/SubItem';
|
|
import { useSettingStore } from '@/store/modules/setting';
|
|
import { usePermissionStore } from '@/store/modules/permission';
|
|
|
|
const route = useRoute();
|
|
const PermissionStore = usePermissionStore();
|
|
const SettingStore = useSettingStore();
|
|
|
|
// 是否折叠
|
|
const isCollapse = computed(() => !SettingStore.isCollapse);
|
|
|
|
// 设置
|
|
const themeConfig = computed(() => SettingStore.themeConfig);
|
|
|
|
// 获取路由
|
|
const permissionRoutes = computed(() => PermissionStore.permissionRoutes);
|
|
|
|
const activeMenu = computed(() => {
|
|
const { meta, path } = route;
|
|
if (meta.activeMenu) {
|
|
return meta.activeMenu;
|
|
}
|
|
return path;
|
|
});
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.layout-sider {
|
|
overflow: hidden;
|
|
position: fixed;
|
|
top: 0;
|
|
bottom: 0;
|
|
left: 0;
|
|
z-index: 98;
|
|
width: 210px;
|
|
height: 100%;
|
|
background-color: #fff;
|
|
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
|
|
transition: width 0.28s;
|
|
|
|
&-scrollbar {
|
|
height: calc(100vh - 60px) !important;
|
|
}
|
|
:deep(.el-scrollbar__wrap) {
|
|
height: calc(100vh - 60px) !important;
|
|
}
|
|
|
|
&-menu {
|
|
border-right: 0;
|
|
|
|
:deep(.el-menu-item.is-active) {
|
|
background-color: #f5f5f5;
|
|
}
|
|
|
|
&:not(.el-menu--collapse) {
|
|
height: 100%;
|
|
}
|
|
}
|
|
}
|
|
</style>
|