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.

185 lines
4.5 KiB

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