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.

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