99 lines
3.0 KiB
Vue
99 lines
3.0 KiB
Vue
<template>
|
|
<div :class="{ 'has-logo': showLogo }" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
|
|
<logo v-if="showLogo && defaultLayout === 'leftRight'" :collapse="isCollapse" />
|
|
<el-scrollbar :class="[sideTheme, defaultLayout === 'topBottom' ? 'topBottom' : 'leftRight']" wrap-class="scrollbar-wrapper">
|
|
<el-menu
|
|
:default-active="activeMenu"
|
|
:collapse="isCollapse"
|
|
:background-color="sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground"
|
|
:text-color="sideTheme === 'theme-dark' ? variables.menuColor : variables.menuLightColor"
|
|
:unique-opened="true"
|
|
:active-text-color="theme"
|
|
:collapse-transition="false"
|
|
mode="vertical"
|
|
>
|
|
<sidebar-item v-for="(route, index) in sidebarRouters" :key="route.path + index" :item="route" :base-path="route.path" />
|
|
</el-menu>
|
|
</el-scrollbar>
|
|
<div class="isShow" @click="toggleSideBar">
|
|
<el-icon :size="20" v-if="isCollapse">
|
|
<ArrowRight />
|
|
</el-icon>
|
|
<el-icon :size="20" v-else>
|
|
<ArrowLeft />
|
|
</el-icon>
|
|
<div class="title" v-if="!isCollapse">收起菜单</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
import Logo from './Logo'
|
|
import SidebarItem from './SidebarItem'
|
|
import variables from '@/assets/styles/variables.module.scss'
|
|
import useAppStore from '@/store/modules/app'
|
|
import useSettingsStore from '@/store/modules/settings'
|
|
import usePermissionStore from '@/store/modules/permission'
|
|
|
|
const route = useRoute()
|
|
const appStore = useAppStore()
|
|
const settingsStore = useSettingsStore()
|
|
const permissionStore = usePermissionStore()
|
|
|
|
const sidebarRouters = computed(() => permissionStore.sidebarRouters)
|
|
const showLogo = computed(() => settingsStore.sidebarLogo)
|
|
const sideTheme = computed(() => settingsStore.sideTheme)
|
|
const theme = computed(() => settingsStore.theme)
|
|
const defaultLayout = computed(() => settingsStore.defaultLayout)
|
|
const isCollapse = computed(() => !appStore.sidebar.opened)
|
|
|
|
const activeMenu = computed(() => {
|
|
const { meta, path } = route
|
|
// if set path, the sidebar will highlight the path you set
|
|
if (meta.activeMenu) {
|
|
return meta.activeMenu
|
|
}
|
|
return path
|
|
})
|
|
|
|
function toggleSideBar() {
|
|
appStore.toggleSideBar()
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.isShow {
|
|
width: 100%;
|
|
height: 0.5rem;
|
|
padding: 0 0.2rem;
|
|
display: flex;
|
|
align-items: center;
|
|
font-family: AppleSystemUIFont;
|
|
color: #8590a5;
|
|
cursor: pointer;
|
|
background: rgb(31, 32, 51);
|
|
.title {
|
|
font-size: 0.13rem;
|
|
margin-left: 0.1rem;
|
|
}
|
|
}
|
|
.isShow:hover {
|
|
color: #ffffff !important;
|
|
background: linear-gradient(
|
|
270deg,
|
|
rgba(95, 224, 255, 0.2) 0%,
|
|
rgba(34, 130, 240, 0.2) 54%,
|
|
rgba(143, 51, 255, 0.2) 100%,
|
|
rgba(9, 239, 226, 0.2) 100%
|
|
) !important;
|
|
}
|
|
.has-logo {
|
|
.topBottom {
|
|
height: calc(100% - 50px);
|
|
}
|
|
.leftRight {
|
|
height: calc(100% - 100px);
|
|
}
|
|
}
|
|
</style>
|