index.vue 1.8 KB

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