index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <script setup lang="ts">
  2. import { useNav } from "@/layout/hooks/useNav";
  3. import LaySearch from "../lay-search/index.vue";
  4. import LayNotice from "../lay-notice/index.vue";
  5. import LayNavMix from "../lay-sidebar/NavMix.vue";
  6. import LaySwitch from "../lay-switch/index.vue";
  7. import LaySidebarFullScreen from "../lay-sidebar/components/SidebarFullScreen.vue";
  8. import LaySidebarBreadCrumb from "../lay-sidebar/components/SidebarBreadCrumb.vue";
  9. import LaySidebarTopCollapse from "../lay-sidebar/components/SidebarTopCollapse.vue";
  10. import LogoutCircleRLine from "~icons/ri/logout-circle-r-line";
  11. import Setting from "~icons/ri/settings-3-line";
  12. import { hasAuth } from "@/router/utils";
  13. import { useUserStoreHook } from "@/store/modules/user";
  14. const {
  15. layout,
  16. device,
  17. logout,
  18. onPanel,
  19. pureApp,
  20. username,
  21. userAvatar,
  22. avatarsStyle,
  23. toggleSideBar
  24. } = useNav();
  25. </script>
  26. <template>
  27. <div class="navbar bg-[#fff] shadow-xs shadow-[rgba(0,21,41,0.08)]">
  28. <LaySidebarTopCollapse
  29. v-if="device === 'mobile'"
  30. class="hamburger-container"
  31. :is-active="pureApp.sidebar.opened"
  32. @toggleClick="toggleSideBar"
  33. />
  34. <LaySidebarBreadCrumb
  35. v-if="layout !== 'mix' && device !== 'mobile'"
  36. class="breadcrumb-container"
  37. />
  38. <LayNavMix v-if="layout === 'mix'" />
  39. <div v-if="layout === 'vertical'" class="vertical-header-right">
  40. <div v-if="useUserStoreHook().isChild">
  41. <LaySwitch id="header-switch" />
  42. </div>
  43. <!-- 菜单搜索 -->
  44. <LaySearch id="header-search" />
  45. <!-- 全屏 -->
  46. <LaySidebarFullScreen id="full-screen" />
  47. <!-- 消息通知 -->
  48. <LayNotice id="header-notice" />
  49. <!-- 退出登录 -->
  50. <el-dropdown trigger="click">
  51. <span class="el-dropdown-link navbar-bg-hover select-none">
  52. <img :src="userAvatar" :style="avatarsStyle" />
  53. <p v-if="username" class="dark:text-white">{{ username }}</p>
  54. </span>
  55. <template #dropdown>
  56. <el-dropdown-menu class="logout">
  57. <el-dropdown-item @click="logout">
  58. <IconifyIconOffline
  59. :icon="LogoutCircleRLine"
  60. style="margin: 5px"
  61. />
  62. 退出系统
  63. </el-dropdown-item>
  64. </el-dropdown-menu>
  65. </template>
  66. </el-dropdown>
  67. <span
  68. class="set-icon navbar-bg-hover"
  69. title="打开系统配置"
  70. @click="onPanel"
  71. >
  72. <IconifyIconOffline :icon="Setting" />
  73. </span>
  74. </div>
  75. </div>
  76. </template>
  77. <style lang="scss" scoped>
  78. .navbar {
  79. width: 100%;
  80. height: 48px;
  81. overflow: hidden;
  82. .hamburger-container {
  83. float: left;
  84. height: 100%;
  85. line-height: 48px;
  86. cursor: pointer;
  87. }
  88. .vertical-header-right {
  89. display: flex;
  90. align-items: center;
  91. justify-content: flex-end;
  92. min-width: 280px;
  93. height: 48px;
  94. color: #000000d9;
  95. .el-dropdown-link {
  96. display: flex;
  97. align-items: center;
  98. justify-content: space-around;
  99. height: 48px;
  100. padding: 10px;
  101. color: #000000d9;
  102. cursor: pointer;
  103. p {
  104. font-size: 14px;
  105. }
  106. img {
  107. width: 22px;
  108. height: 22px;
  109. border-radius: 50%;
  110. }
  111. }
  112. }
  113. .breadcrumb-container {
  114. float: left;
  115. margin-left: 16px;
  116. }
  117. }
  118. .logout {
  119. width: 120px;
  120. ::v-deep(.el-dropdown-menu__item) {
  121. display: inline-flex;
  122. flex-wrap: wrap;
  123. min-width: 100%;
  124. }
  125. }
  126. </style>