navBar.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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">
  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="localeStore.setCurrentLocale(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 { reactive, ref } from 'vue'
  73. import { getToken } from '@/utils/auth'
  74. import { useUserStore } from '@/store/user'
  75. import { useLocaleStore } from '@/store/locale'
  76. defineOptions({ name: 'personal-navbar' })
  77. defineProps({
  78. sticky: {
  79. type: Boolean,
  80. default: true
  81. }
  82. })
  83. const localeStore = useLocaleStore()
  84. const userStore = useUserStore()
  85. import { useRouter } from 'vue-router'
  86. const router = useRouter()
  87. const handleLogoClick = () => { router.push({ path: '/enterprise/home'}) }
  88. const show = ref(false)
  89. const userType = ref(0) // 0企业用户、1个人用户
  90. const changeRole = () => {
  91. if (userType.value) {
  92. show.value = true
  93. router.push({ path: '/enterprise/register' })
  94. } else {
  95. // 重新走登录拿数据
  96. }
  97. }
  98. const handleToPersonalCenter = () => {
  99. // router.push({ path: '/personalCenter' })
  100. }
  101. // 退出登录
  102. const handleLogout = async () => {
  103. await userStore.userLogout()
  104. router.push({ path: '/login' })
  105. }
  106. const items = ref([
  107. { title: '联系人信息', icon: 'mdi-account-outline', change: () => router.push({ path: '/resume' }) },
  108. { title: '账号管理', icon: 'mdi-cog-outline', change: () => router.push({ path: '/personalAccount/accountBinding' }) },
  109. { title: '切换为求职者', icon: 'mdi-swap-horizontal', change: changeRole },
  110. { title: '退出登录', icon: 'mdi-logout', change: handleLogout }
  111. ])
  112. const baseInfo = reactive(JSON.parse(localStorage.getItem('baseInfo'))) // 人才信息
  113. </script>
  114. <style lang="scss" scoped>
  115. .banner {
  116. width: 100%;
  117. height: 50px;
  118. z-index: var(--zIndex-nav) !important;
  119. color: #fff;
  120. background-color: #d5e6e8;
  121. padding-left: 0px;
  122. height: 50px;
  123. font-size: 15px;
  124. .left {
  125. height: 100%;
  126. display: flex;
  127. align-items: center;
  128. font-size: 20px;
  129. cursor: pointer;
  130. }
  131. }
  132. .hover:hover {
  133. cursor: pointer;
  134. background: rgba(0, 0, 0, 0.03);
  135. }
  136. .innerBox {
  137. position: relative;
  138. width: 100%;
  139. align-items: center;
  140. padding: 0 30px;
  141. }
  142. .nav-logo {
  143. float: left;
  144. }
  145. .nav {
  146. font-size: 0;
  147. float: left;
  148. margin-left: 50px;
  149. height: 49px;
  150. line-height: 49px;
  151. }
  152. .user-nav {
  153. color: var(--v-primary-base);
  154. }
  155. .line {
  156. width: 1px;
  157. height: 25px;
  158. background-color: #fff;
  159. margin: 0 10px;
  160. margin: 8px 0 0 29px;
  161. }
  162. </style>