You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
1.9 KiB

  1. <script setup lang="ts">
  2. import { ref } from "vue";
  3. import { noticesData } from "./data";
  4. import NoticeList from "./noticeList.vue";
  5. const noticesNum = ref(0);
  6. const notices = ref(noticesData);
  7. const activeKey = ref(noticesData[0].key);
  8. notices.value.map(v => (noticesNum.value += v.list.length));
  9. </script>
  10. <template>
  11. <el-dropdown trigger="click" placement="bottom-end">
  12. <span class="dropdown-badge navbar-bg-hover select-none">
  13. <el-badge :value="noticesNum" :max="99">
  14. <span class="header-notice-icon">
  15. <IconifyIconOffline icon="bell" />
  16. </span>
  17. </el-badge>
  18. </span>
  19. <template #dropdown>
  20. <el-dropdown-menu>
  21. <el-tabs :stretch="true" v-model="activeKey" class="dropdown-tabs">
  22. <template v-for="item in notices" :key="item.key">
  23. <el-tab-pane
  24. :label="`${item.name}(${item.list.length})`"
  25. :name="`${item.key}`"
  26. >
  27. <el-scrollbar max-height="330px">
  28. <div class="noticeList-container">
  29. <NoticeList :list="item.list" />
  30. </div>
  31. </el-scrollbar>
  32. </el-tab-pane>
  33. </template>
  34. </el-tabs>
  35. </el-dropdown-menu>
  36. </template>
  37. </el-dropdown>
  38. </template>
  39. <style lang="scss" scoped>
  40. .dropdown-badge {
  41. display: flex;
  42. align-items: center;
  43. justify-content: center;
  44. height: 48px;
  45. width: 60px;
  46. cursor: pointer;
  47. .header-notice-icon {
  48. font-size: 18px;
  49. }
  50. }
  51. .dropdown-tabs {
  52. width: 330px;
  53. .noticeList-container {
  54. padding: 15px 24px 0 24px;
  55. }
  56. :deep(.el-tabs__header) {
  57. margin: 0;
  58. }
  59. :deep(.el-tabs__nav-wrap)::after {
  60. height: 1px;
  61. }
  62. // 如果上面的 notices 长度大于 3 请注释掉下面代码
  63. :deep(.el-tabs__nav-wrap) {
  64. padding: 0 36px 0 36px;
  65. }
  66. // 如果上面的 notices 长度大于 3 请注释掉下面代码
  67. :deep(.el-tabs__active-bar) {
  68. margin: 0 36px 0 36px;
  69. }
  70. }
  71. </style>