navBar.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <div>
  3. <v-toolbar
  4. class="banner"
  5. density="compact"
  6. style="padding-left: 0px;height: 50px;font-size: 14px;"
  7. >
  8. <div class="innerBox d-flex justify-space-between">
  9. <div>
  10. <div class="nav-logo" style="cursor: pointer;" @click="handleLogoClick">
  11. <v-img src="../../assets/logo.png" aspect-ratio="16/9" cover :width="90" style="height: 40px"></v-img>
  12. </div>
  13. </div>
  14. <div class="d-flex user-nav">
  15. <div class="d-flex align-center cursor-pointer" @click="handleEnterpriseClick">
  16. <v-img @click="enterpriseClick(2)" rounded width="40" height="40" :src="baseInfo?.logoUrl || 'https://minio.citupro.com/dev/menduner/7.png'" ></v-img>
  17. <span @click="enterpriseClick(1)" class="ml-3">{{ baseInfo?.enterpriseName || $t('sys.tourist') }}</span>
  18. </div>
  19. <div class="line"></div>
  20. <!-- 头像用户名 -->
  21. <div class="d-flex align-center" v-if="getToken()">
  22. <v-menu open-on-hover>
  23. <template v-slot:activator="{ props }">
  24. <div class="d-flex ml-5 pl-2 align-center cursor-pointer" v-bind="props" @click="handleToPersonalCenter">
  25. <v-avatar>
  26. <v-img alt="" :src="baseInfo?.avatar || 'https://minio.citupro.com/dev/menduner/7.png'"></v-img>
  27. </v-avatar>
  28. <div class="ml-2">{{ baseInfo?.name ?? $t('sys.tourist') }}</div>
  29. </div>
  30. </template>
  31. <v-list>
  32. <v-list-item v-for="(item, index) in items" :key="index" @click="item.change">
  33. <template v-slot:prepend>
  34. <v-icon :icon="item.icon"></v-icon>
  35. </template>
  36. <v-list-item-title>{{ item.title }}</v-list-item-title>
  37. </v-list-item>
  38. </v-list>
  39. </v-menu>
  40. </div>
  41. <!-- 语言切换 -->
  42. <v-menu>
  43. <template v-slot:activator="{ props }">
  44. <v-btn
  45. class="ml-3"
  46. color="primary"
  47. size="small"
  48. icon="mdi-translate"
  49. v-bind="props"
  50. >
  51. </v-btn>
  52. </template>
  53. <v-list density="compact">
  54. <v-list-item
  55. v-for="item in localeStore.localeMap"
  56. :key="item.name"
  57. :value="item.lang"
  58. :active="localeStore.currentLocale.lang === item.lang"
  59. @click="handleChangeLocale(item)"
  60. >
  61. <v-list-item-title>{{ item.name }}</v-list-item-title>
  62. </v-list-item>
  63. </v-list>
  64. </v-menu>
  65. <v-btn size="small" icon="mdi-bell-outline"></v-btn>
  66. </div>
  67. </div>
  68. </v-toolbar>
  69. </div>
  70. </template>
  71. <script setup>
  72. import { ref } from 'vue'
  73. import { getToken } from '@/utils/auth'
  74. import { useUserStore } from '@/store/user'
  75. import { useLocaleStore } from '@/store/locale'
  76. import { useI18n } from '@/hooks/web/useI18n'
  77. defineOptions({ name: 'personal-navbar' })
  78. defineProps({
  79. sticky: {
  80. type: Boolean,
  81. default: true
  82. }
  83. })
  84. const { t } = useI18n()
  85. const localeStore = useLocaleStore()
  86. const userStore = useUserStore()
  87. import { useRouter } from 'vue-router'
  88. const router = useRouter()
  89. const handleLogoClick = () => { router.push({ path: '/enterprise'}) }
  90. const handleToPersonalCenter = () => {
  91. // router.push({ path: '/personalCenter' })
  92. }
  93. const handleEnterpriseClick = () => {
  94. // router.push({ path: '/enterprise/enterpriseCenter?key=mIntroduction' })
  95. }
  96. const enterpriseClick = (tabKey = 1) => {
  97. const path = '/enterprise/informationManagement/informationSettings'
  98. router.push({ path, query: { tabKey } })
  99. }
  100. // 退出登录
  101. const handleLogout = async () => {
  102. await userStore.userLogout(2)
  103. router.push({ path: '/login' })
  104. }
  105. const items = ref([
  106. { title: t('enterprise.personalInformationSettings'), icon: 'mdi-account-cog', change: () => router.push({ path: '/enterprise/informationSettings' }) },
  107. { title: t('setting.switchToJobSeeker'), icon: 'mdi-swap-horizontal', change: handleLogout },
  108. { title: t('setting.logOut'), icon: 'mdi-logout', change: handleLogout }
  109. ])
  110. // 企业logo、用户基本信息
  111. let baseInfo = ref(JSON.parse(localStorage.getItem('baseInfo')) || {})
  112. userStore.$subscribe((mutation, state) => {
  113. baseInfo.value = state.baseInfo
  114. })
  115. // 语言切换
  116. const handleChangeLocale = (item) => {
  117. localeStore.setCurrentLocale(item)
  118. location.reload()
  119. }
  120. </script>
  121. <style lang="scss" scoped>
  122. .banner {
  123. width: 100%;
  124. height: 50px;
  125. z-index: var(--zIndex-nav) !important;
  126. color: #fff;
  127. background-color: #d5e6e8;
  128. padding-left: 0px;
  129. height: 50px;
  130. font-size: 15px;
  131. .left {
  132. height: 100%;
  133. display: flex;
  134. align-items: center;
  135. font-size: 20px;
  136. cursor: pointer;
  137. }
  138. }
  139. .hover:hover {
  140. cursor: pointer;
  141. background: rgba(0, 0, 0, 0.03);
  142. }
  143. .innerBox {
  144. position: relative;
  145. width: 100%;
  146. align-items: center;
  147. padding: 0 30px;
  148. }
  149. .nav-logo {
  150. float: left;
  151. }
  152. .nav {
  153. font-size: 0;
  154. float: left;
  155. margin-left: 50px;
  156. height: 49px;
  157. line-height: 49px;
  158. }
  159. .user-nav {
  160. color: var(--v-primary-base);
  161. }
  162. .line {
  163. width: 1px;
  164. height: 25px;
  165. background-color: #fff;
  166. margin: 0 10px;
  167. margin: 8px 0 0 29px;
  168. }
  169. </style>