index.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <script setup>
  2. import SidebarItem from './SidebarItem'
  3. import useSettingsStore from '@/store/modules/settings'
  4. import usePermissionStore from '@/store/modules/permission'
  5. const route = useRoute();
  6. const router = useRouter();
  7. const settingsStore = useSettingsStore()
  8. const permissionStore = usePermissionStore()
  9. const sidebarRouters = computed(() => permissionStore.sidebarRouters);
  10. const theme = computed(() => settingsStore.theme);
  11. const activeKey = ref(route.path);
  12. const activeMenu = computed(() => {
  13. const { meta, path } = route;
  14. // if set path, the sidebar will highlight the path you set
  15. if (meta.activeMenu) {
  16. return meta.activeMenu;
  17. }
  18. return path;
  19. })
  20. const menuResetTheme = {
  21. '--el-menu-bg-color': '#EFF1F8',
  22. '--el-menu-text-color': '#4E5969',
  23. '--el-menu-active-color': '#165DFF',
  24. '--el-menu-item-height': '48px'
  25. }
  26. const handleSelect = (key) => {
  27. activeKey.value = key;
  28. }
  29. const onJumpPage = () => {
  30. const { href } = router.resolve({
  31. path: '/voice/dashboard'
  32. });
  33. window.open(href, '_blank');
  34. }
  35. </script>
  36. <template>
  37. <div :style="{ backgroundColor: '#EFF1F8', paddingTop: '20px' }" class="vocie-menu-wrapper">
  38. <el-scrollbar :class="theme" wrap-class="scrollbar-wrapper">
  39. <div style="padding: 0 20px;">
  40. <el-menu :style="menuResetTheme" :default-active="activeMenu" :unique-opened="true" :collapse-transition="false"
  41. mode="vertical" @select="handleSelect">
  42. <sidebar-item v-for="(route, index) in sidebarRouters" :key="route.path + index" :item="route"
  43. :base-path="route.path" :active-key="activeKey" />
  44. </el-menu>
  45. </div>
  46. </el-scrollbar>
  47. <!-- <div class="vocie-menu-footer">
  48. <div class="dashboard-btn space-x-[10px]" @click="onJumpPage">
  49. <el-icon><TrendCharts /></el-icon>
  50. <span class="text-[14px]">驾驶舱</span>
  51. </div>
  52. </div> -->
  53. </div>
  54. </template>
  55. <style lang="scss">
  56. #app .sidebar-container .el-scrollbar {
  57. height: calc(100% - 60px);
  58. }
  59. .vocie-menu-footer {
  60. height: 60px;
  61. padding: 20px;
  62. .dashboard-btn {
  63. display: flex;
  64. align-items: center;
  65. justify-content: center;
  66. height: 36px;
  67. border-radius: 8px;
  68. border: 1px solid #e4e4e4;
  69. // color: #165DFF;
  70. color: #666;
  71. font-size: 16px;
  72. cursor: pointer;
  73. transition: all 0.6s;
  74. &:hover {
  75. color: #165DFF;
  76. background: linear-gradient(90deg, #FFF 0%, rgba(255, 255, 255, 0) 100%);
  77. }
  78. }
  79. }
  80. </style>