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.

188 lines
4.6 KiB

3 years ago
3 years ago
  1. <script setup lang="ts">
  2. import Search from "./search/index.vue";
  3. import Notice from "./notice/index.vue";
  4. import mixNav from "./sidebar/mixNav.vue";
  5. import { useNav } from "@/layout/hooks/useNav";
  6. import Breadcrumb from "./sidebar/breadCrumb.vue";
  7. import topCollapse from "./sidebar/topCollapse.vue";
  8. import { useTranslationLang } from "../hooks/useTranslationLang";
  9. import globalization from "@/assets/svg/globalization.svg?component";
  10. import LogoutCircleRLine from "@iconify-icons/ri/logout-circle-r-line";
  11. import Setting from "@iconify-icons/ri/settings-3-line";
  12. import Check from "@iconify-icons/ep/check";
  13. const {
  14. layout,
  15. device,
  16. logout,
  17. onPanel,
  18. pureApp,
  19. username,
  20. userAvatar,
  21. avatarsStyle,
  22. toggleSideBar,
  23. getDropdownItemStyle,
  24. getDropdownItemClass
  25. } = useNav();
  26. const { t, locale, translationCh, translationEn } = useTranslationLang();
  27. </script>
  28. <template>
  29. <div
  30. class="navbar bg-[#fff] shadow-sm shadow-[rgba(0, 21, 41, 0.08)] dark:shadow-[#0d0d0d]"
  31. >
  32. <topCollapse
  33. v-if="device === 'mobile'"
  34. class="hamburger-container"
  35. :is-active="pureApp.sidebar.opened"
  36. @toggleClick="toggleSideBar"
  37. />
  38. <Breadcrumb
  39. v-if="layout !== 'mix' && device !== 'mobile'"
  40. class="breadcrumb-container"
  41. />
  42. <mixNav v-if="layout === 'mix'" />
  43. <div v-if="layout === 'vertical'" class="vertical-header-right">
  44. <!-- 菜单搜索 -->
  45. <Search />
  46. <!-- 通知 -->
  47. <Notice id="header-notice" />
  48. <!-- 国际化 -->
  49. <el-dropdown id="header-translation" trigger="click">
  50. <globalization
  51. class="navbar-bg-hover w-[40px] h-[48px] p-[11px] cursor-pointer outline-none"
  52. />
  53. <template #dropdown>
  54. <el-dropdown-menu class="translation">
  55. <el-dropdown-item
  56. :style="getDropdownItemStyle(locale, 'zh')"
  57. :class="['dark:!text-white', getDropdownItemClass(locale, 'zh')]"
  58. @click="translationCh"
  59. >
  60. <IconifyIconOffline
  61. class="check-zh"
  62. v-show="locale === 'zh'"
  63. :icon="Check"
  64. />
  65. 简体中文
  66. </el-dropdown-item>
  67. <el-dropdown-item
  68. :style="getDropdownItemStyle(locale, 'en')"
  69. :class="['dark:!text-white', getDropdownItemClass(locale, 'en')]"
  70. @click="translationEn"
  71. >
  72. <span class="check-en" v-show="locale === 'en'">
  73. <IconifyIconOffline :icon="Check" />
  74. </span>
  75. English
  76. </el-dropdown-item>
  77. </el-dropdown-menu>
  78. </template>
  79. </el-dropdown>
  80. <!-- 退出登录 -->
  81. <el-dropdown trigger="click">
  82. <span class="el-dropdown-link navbar-bg-hover select-none">
  83. <img :src="userAvatar" :style="avatarsStyle" />
  84. <p v-if="username" class="dark:text-white">{{ username }}</p>
  85. </span>
  86. <template #dropdown>
  87. <el-dropdown-menu class="logout">
  88. <el-dropdown-item @click="logout">
  89. <IconifyIconOffline
  90. :icon="LogoutCircleRLine"
  91. style="margin: 5px"
  92. />
  93. {{ t("buttons.hsLoginOut") }}
  94. </el-dropdown-item>
  95. </el-dropdown-menu>
  96. </template>
  97. </el-dropdown>
  98. <span
  99. class="set-icon navbar-bg-hover"
  100. :title="t('buttons.hssystemSet')"
  101. @click="onPanel"
  102. >
  103. <IconifyIconOffline :icon="Setting" />
  104. </span>
  105. </div>
  106. </div>
  107. </template>
  108. <style lang="scss" scoped>
  109. .navbar {
  110. width: 100%;
  111. height: 48px;
  112. overflow: hidden;
  113. .hamburger-container {
  114. float: left;
  115. height: 100%;
  116. line-height: 48px;
  117. cursor: pointer;
  118. }
  119. .vertical-header-right {
  120. display: flex;
  121. align-items: center;
  122. justify-content: flex-end;
  123. min-width: 280px;
  124. height: 48px;
  125. color: #000000d9;
  126. .el-dropdown-link {
  127. display: flex;
  128. align-items: center;
  129. justify-content: space-around;
  130. height: 48px;
  131. padding: 10px;
  132. color: #000000d9;
  133. cursor: pointer;
  134. p {
  135. font-size: 14px;
  136. }
  137. img {
  138. width: 22px;
  139. height: 22px;
  140. border-radius: 50%;
  141. }
  142. }
  143. }
  144. .breadcrumb-container {
  145. float: left;
  146. margin-left: 16px;
  147. }
  148. }
  149. .translation {
  150. ::v-deep(.el-dropdown-menu__item) {
  151. padding: 5px 40px;
  152. }
  153. .check-zh {
  154. position: absolute;
  155. left: 20px;
  156. }
  157. .check-en {
  158. position: absolute;
  159. left: 20px;
  160. }
  161. }
  162. .logout {
  163. max-width: 120px;
  164. ::v-deep(.el-dropdown-menu__item) {
  165. display: inline-flex;
  166. flex-wrap: wrap;
  167. min-width: 100%;
  168. }
  169. }
  170. </style>