index.vue 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <div :class="{ 'has-logo': showLogo }" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
  3. <logo v-if="showLogo" :collapse="isCollapse" />
  4. <el-scrollbar :class="sideTheme" wrap-class="scrollbar-wrapper">
  5. <el-menu
  6. :default-active="activeMenu"
  7. :collapse="isCollapse"
  8. :background-color="sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground"
  9. :text-color="sideTheme === 'theme-dark' ? variables.menuColor : variables.menuLightColor"
  10. :unique-opened="true"
  11. :active-text-color="theme"
  12. :collapse-transition="false"
  13. mode="vertical"
  14. >
  15. <sidebar-item
  16. v-for="(route, index) in sidebarRouters"
  17. :key="route.path + index"
  18. :item="route"
  19. :base-path="route.path"
  20. :badgeObj="badgeObj"
  21. />
  22. </el-menu>
  23. </el-scrollbar>
  24. </div>
  25. </template>
  26. <script setup>
  27. import Logo from './Logo'
  28. import SidebarItem from './SidebarItem'
  29. import variables from '@/assets/styles/variables.module.scss'
  30. import useAppStore from '@/store/modules/app'
  31. import useSettingsStore from '@/store/modules/settings'
  32. import usePermissionStore from '@/store/modules/permission'
  33. import { MessaGeUnreadMessageCount } from "@/api/InformationWrapper/index"
  34. import useSidebarStore from "@/store/modules/sidebar";
  35. const route = useRoute();
  36. const appStore = useAppStore()
  37. const settingsStore = useSettingsStore()
  38. const permissionStore = usePermissionStore()
  39. const sidebarStore = useSidebarStore()
  40. const sidebarRouters = computed(() => permissionStore.sidebarRouters);
  41. const showLogo = computed(() => settingsStore.sidebarLogo);
  42. const sideTheme = computed(() => settingsStore.sideTheme);
  43. const theme = computed(() => settingsStore.theme);
  44. const isCollapse = computed(() => !appStore.sidebar.opened);
  45. const activeMenu = computed(() => {
  46. const { meta, path } = route;
  47. // if set path, the sidebar will highlight the path you set
  48. if (meta.activeMenu) {
  49. return meta.activeMenu;
  50. }
  51. return path;
  52. })
  53. // const badgeObj = ref({
  54. // xxtzGqxxtzNum: '0' // 消息通知-股权消息通知
  55. // })
  56. const badgeObj = computed(() => sidebarStore.badgeObj)
  57. const unreadCount = ref(0); // 存储未读消息数量
  58. // 获取未读数量
  59. // function getOnList(){
  60. // MessaGeUnreadMessageCount().then(res=>{
  61. // if(res.code == 200){
  62. // badgeObj.value.xxtzGqxxtzNum = res.data;
  63. // }
  64. // })
  65. // }
  66. // 获取未读数量,确保只在组件挂载时请求一次
  67. onMounted(() => {
  68. // getOnList();
  69. sidebarStore.getOnList()
  70. });
  71. </script>