| | |
| | | <template> |
| | | <div :class="{ 'has-logo': showLogo }" class="sidebar-container"> |
| | | <logo v-if="showLogo" :collapse="isCollapse" /> |
| | | <div :class="{ 'has-logo': showLogo && appStore.device === 'mobile' }" |
| | | class="sidebar-container"> |
| | | <logo v-if="showLogo && appStore.device === 'mobile'" |
| | | :collapse="false" /> |
| | | <el-scrollbar wrap-class="scrollbar-wrapper"> |
| | | <el-menu |
| | | :default-active="activeMenu" |
| | | :collapse="isCollapse" |
| | | :background-color="getMenuBackground" |
| | | :text-color="getMenuTextColor" |
| | | :unique-opened="true" |
| | | :active-text-color="theme" |
| | | :collapse-transition="false" |
| | | mode="vertical" |
| | | :class="sideTheme" |
| | | > |
| | | <sidebar-item |
| | | v-for="(route, index) in sidebarRouters" |
| | | :key="route.path + index" |
| | | :item="route" |
| | | :base-path="route.path" |
| | | /> |
| | | <el-menu :default-active="activeMenu" |
| | | :collapse="isCollapse" |
| | | :background-color="getMenuBackground" |
| | | :text-color="getMenuTextColor" |
| | | :unique-opened="true" |
| | | :active-text-color="theme" |
| | | :collapse-transition="false" |
| | | mode="vertical" |
| | | :class="sideTheme"> |
| | | <sidebar-item v-for="(route, index) in sidebarRouters" |
| | | :key="route.path + index" |
| | | :item="route" |
| | | :base-path="route.path" /> |
| | | </el-menu> |
| | | </el-scrollbar> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | | import Logo from "./Logo"; |
| | | import SidebarItem from "./SidebarItem"; |
| | | import useAppStore from "@/store/modules/app"; |
| | | import useSettingsStore from "@/store/modules/settings"; |
| | | import usePermissionStore from "@/store/modules/permission"; |
| | | import Logo from "./Logo"; |
| | | import SidebarItem from "./SidebarItem"; |
| | | 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 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 isCollapse = computed(() => !appStore.sidebar.opened); |
| | | const sidebarRouters = computed(() => permissionStore.sidebarRouters); |
| | | const showLogo = computed(() => settingsStore.sidebarLogo); |
| | | const sideTheme = computed(() => settingsStore.sideTheme); |
| | | const theme = computed(() => settingsStore.theme); |
| | | const isCollapse = computed(() => !appStore.sidebar.opened); |
| | | |
| | | const getMenuBackground = computed(() => "var(--sidebar-bg)"); |
| | | const getMenuBackground = computed(() => "var(--sidebar-bg)"); |
| | | |
| | | const getMenuTextColor = computed(() => "var(--sidebar-text)"); |
| | | const getMenuTextColor = computed(() => "var(--sidebar-text)"); |
| | | |
| | | const activeMenu = computed(() => { |
| | | const { meta, path } = route; |
| | | if (meta.activeMenu) return meta.activeMenu; |
| | | return path; |
| | | }); |
| | | const activeMenu = computed(() => { |
| | | const { meta, path } = route; |
| | | if (meta.activeMenu) return meta.activeMenu; |
| | | return path; |
| | | }); |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .sidebar-container { |
| | | background: transparent; |
| | | border-radius: 0; |
| | | overflow: hidden; |
| | | |
| | | .scrollbar-wrapper { |
| | | .sidebar-container { |
| | | background: transparent; |
| | | } |
| | | border-radius: 0; |
| | | overflow: hidden; |
| | | display: flex; |
| | | flex-direction: column; |
| | | |
| | | .el-menu { |
| | | border: none !important; |
| | | height: 100%; |
| | | width: 100% !important; |
| | | background: transparent !important; |
| | | |
| | | :deep(.el-menu-item), |
| | | :deep(.el-sub-menu__title) { |
| | | margin-bottom: 4px; |
| | | border-radius: var(--radius-md); |
| | | color: var(--sidebar-text); |
| | | font-size: 14px; |
| | | transition: all 0.2s ease; |
| | | display: flex; |
| | | align-items: center; |
| | | |
| | | &:hover { |
| | | background: var(--menu-hover) !important; |
| | | color: #fff !important; |
| | | } |
| | | .scrollbar-wrapper { |
| | | background: transparent; |
| | | } |
| | | |
| | | :deep(.el-menu-item.is-active) { |
| | | background: var(--menu-active-bg) !important; |
| | | color: var(--menu-active-text) !important; |
| | | font-weight: 600; |
| | | box-shadow: var(--menu-active-glow); |
| | | .el-menu { |
| | | border: none !important; |
| | | height: 100%; |
| | | width: 100% !important; |
| | | background: transparent !important; |
| | | |
| | | .svg-icon { |
| | | :deep(.el-menu-item), |
| | | :deep(.el-sub-menu__title) { |
| | | margin-bottom: 4px; |
| | | border-radius: var(--radius-md); |
| | | color: var(--sidebar-text); |
| | | font-size: 14px; |
| | | transition: all 0.2s ease; |
| | | display: flex; |
| | | align-items: center; |
| | | |
| | | &:hover { |
| | | background: var(--menu-hover) !important; |
| | | color: #fff !important; |
| | | } |
| | | } |
| | | |
| | | :deep(.el-menu-item.is-active) { |
| | | background: var(--menu-active-bg) !important; |
| | | color: var(--menu-active-text) !important; |
| | | font-weight: 600; |
| | | box-shadow: var(--menu-active-glow); |
| | | |
| | | .svg-icon { |
| | | color: var(--menu-active-text) !important; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | </style> |