HeaderWrap.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <script setup>
  2. import { useLayoutState } from '../hooks/index'
  3. import { useRoute, useRouter } from 'vue-router'
  4. import NoticeWrap from './NoticeWrap.vue'
  5. import {apiSystemMessage} from '@/api/system'
  6. const { menuClose, menuCloseChange } = useLayoutState()
  7. const router=useRouter()
  8. const route=useRoute()
  9. const breadcrumbArr=computed(()=>{
  10. const arr=route.matched
  11. let temarr=arr.map(item=>{
  12. return item.meta
  13. })
  14. if(arr[1]&&arr[1].meta.from){
  15. temarr.splice(1,0,{title:arr[1].meta.from})
  16. }
  17. return temarr
  18. })
  19. function handleClickBreadcrumb(e){
  20. // router.push()
  21. }
  22. // 阅读消息
  23. function handleReadNotice(){
  24. apiSystemMessage.msgRead().then(res=>{
  25. if(res.Ret===200){
  26. hasUnRead.value=false
  27. }
  28. })
  29. }
  30. const hasUnRead=ref(false)//是否有未读
  31. </script>
  32. <template>
  33. <div class="flex header-wrap">
  34. <img src="@/assets/imgs/logo.png" alt="" class="logo-img">
  35. <!-- 折叠按钮 -->
  36. <el-icon size="26px" v-if="menuClose" @click="menuCloseChange"
  37. ><i-ep-Expand
  38. /></el-icon>
  39. <el-icon size="26px" v-else @click="menuCloseChange"><i-ep-Fold /></el-icon>
  40. <!-- 面包屑 -->
  41. <el-breadcrumb separator="/" style="margin-left: 30px">
  42. <el-breadcrumb-item v-for="item in breadcrumbArr" :key="item.title" @click="handleClickBreadcrumb(item)">{{
  43. item.title
  44. }}</el-breadcrumb-item>
  45. </el-breadcrumb>
  46. <div class="content"></div>
  47. <!-- 通知 -->
  48. <el-popover placement="bottom" :width="500" trigger="click" @show="handleReadNotice" v-if="hasPermission('message:info')">
  49. <template #reference>
  50. <div :class="['system-notice-box',hasUnRead?'system-notice-box_red':'']">
  51. <svg-icon name="notification-filled" size="18px"></svg-icon>
  52. </div>
  53. </template>
  54. <NoticeWrap @change="e=>hasUnRead=e"/>
  55. </el-popover>
  56. </div>
  57. </template>
  58. <style lang="scss" scoped>
  59. .header-wrap {
  60. position: fixed;
  61. left: 0px;
  62. top: 0;
  63. right: 0;
  64. height: 60px;
  65. z-index: 50;
  66. background-color: #091F6B;
  67. box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
  68. padding: 0 30px 0 0;
  69. align-items: center;
  70. color: #fff;
  71. .logo-img{
  72. width: 200px;
  73. height: 100%;
  74. margin-right: 30px;
  75. }
  76. :deep(.el-breadcrumb__item){
  77. .el-breadcrumb__inner{
  78. color: #fff;
  79. }
  80. }
  81. .content {
  82. flex: 1;
  83. }
  84. .system-notice-box{
  85. position: relative;
  86. &.system-notice-box_red::after{
  87. content: '';
  88. display: block;
  89. width: 6px;
  90. height: 6px;
  91. background-color: #f00;
  92. border-radius: 6px;
  93. position: absolute;
  94. top: -2px;
  95. right: -2px;
  96. }
  97. }
  98. }
  99. </style>