navBar.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 rounded width="40" height="40" src="https://minio.citupro.com/dev/menduner/7.png" ></v-img>
  17. <span class="ml-3">广州辞图科技有限公司</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 changeRole = () => {
  91. // router.push({ path: '/' })
  92. // }
  93. const handleToPersonalCenter = () => {
  94. // router.push({ path: '/personalCenter' })
  95. }
  96. const handleEnterpriseClick = () => {
  97. router.push({ path: '/enterprise/enterpriseCenter' })
  98. }
  99. // 退出登录
  100. const handleLogout = async () => {
  101. await userStore.userLogout()
  102. router.push({ path: '/login' })
  103. }
  104. const items = ref([
  105. // { title: '联系人信息', icon: 'mdi-account-outline', change: () => router.push({ path: '/resume' }) },
  106. // { title: '账号管理', icon: 'mdi-cog-outline', change: () => router.push({ path: '/personalAccount/accountBinding' }) },
  107. { title: t('setting.switchToJobSeeker'), icon: 'mdi-swap-horizontal', change: handleLogout },
  108. { title: t('setting.logOut'), icon: 'mdi-logout', change: handleLogout }
  109. ])
  110. const baseInfo = JSON.parse(localStorage.getItem('baseInfo')) // 人才信息
  111. // 语言切换
  112. const handleChangeLocale = (item) => {
  113. localeStore.setCurrentLocale(item)
  114. location.reload()
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. .banner {
  119. width: 100%;
  120. height: 50px;
  121. z-index: var(--zIndex-nav) !important;
  122. color: #fff;
  123. background-color: #d5e6e8;
  124. padding-left: 0px;
  125. height: 50px;
  126. font-size: 15px;
  127. .left {
  128. height: 100%;
  129. display: flex;
  130. align-items: center;
  131. font-size: 20px;
  132. cursor: pointer;
  133. }
  134. }
  135. .hover:hover {
  136. cursor: pointer;
  137. background: rgba(0, 0, 0, 0.03);
  138. }
  139. .innerBox {
  140. position: relative;
  141. width: 100%;
  142. align-items: center;
  143. padding: 0 30px;
  144. }
  145. .nav-logo {
  146. float: left;
  147. }
  148. .nav {
  149. font-size: 0;
  150. float: left;
  151. margin-left: 50px;
  152. height: 49px;
  153. line-height: 49px;
  154. }
  155. .user-nav {
  156. color: var(--v-primary-base);
  157. }
  158. .line {
  159. width: 1px;
  160. height: 25px;
  161. background-color: #fff;
  162. margin: 0 10px;
  163. margin: 8px 0 0 29px;
  164. }
  165. </style>