Nav.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <header class="header">
  3. <img :src="logo" alt="logo" class="header__logo" />
  4. <span class="platform-name">{{ title }}</span>
  5. <nav class="header__nav">
  6. <div
  7. class="header__nav--item"
  8. v-for="item in NAV_LIST"
  9. :key="item.path"
  10. :class="{ active: selectedKey === item.name }"
  11. @click="handleNavClick(item)"
  12. >
  13. <span>{{ item.meta?.title }}</span>
  14. </div>
  15. </nav>
  16. <SwitchTenant v-if="userStore.info.tenantId === SYS_TENANT_ID" />
  17. <div class="platform__right">
  18. <div class="platform__right__search">
  19. <el-input v-model="searchValue" placeholder="搜索您想了解的" class="input-with-icon" clearable>
  20. <template #prepend>
  21. <img :src="searchIcon" alt="search" class="search-icon" @click="handleSearch" />
  22. </template>
  23. </el-input>
  24. </div>
  25. <div class="platform__right__login">
  26. <span @click="userStore.showLogin = true" v-if="!userStore.info?.id">登录</span>
  27. <UserInfo v-else />
  28. </div>
  29. </div>
  30. </header>
  31. <Login v-if="userStore.showLogin" @close="userStore.showLogin = false" class="fadeIn" />
  32. <SwitchAccount v-if="userStore.showSwitchAccount" @close="userStore.showSwitchAccount = false" class="fadeIn" />
  33. <UpdatePwd v-if="userStore.showUpdatePwd" @close="userStore.showUpdatePwd = false" class="fadeIn" />
  34. </template>
  35. <script lang="ts" setup>
  36. import { ref, computed } from 'vue';
  37. import { useRouter, useRoute } from 'vue-router';
  38. import UpdatePwd from '@/components/UpdatePwd.vue';
  39. import UserInfo from '@/components/UserInfo.vue';
  40. import Login from '@/components/Login/Login.vue';
  41. import SwitchAccount from '@/components/Login/SwitchAccount.vue';
  42. import SwitchTenant from '@/layout/components/SwitchTenant.vue';
  43. import { useUserStore } from '@/store/modules/user';
  44. import { useGlobSetting } from '@/hooks/setting';
  45. import { SYS_TENANT_ID } from '@/utils/useTargetTenantIdSetting';
  46. import { NAV_LIST } from '@/constant/nav';
  47. import logo from 'assets/images/home/comac-logo@1X.png';
  48. import searchIcon from 'assets/svg/search.svg';
  49. const userStore = useUserStore();
  50. const activeNav = ref(NAV_LIST[0].name);
  51. const router = useRouter();
  52. const searchValue = ref('');
  53. const handleSearch = () => {
  54. console.log('searchValue', searchValue.value);
  55. };
  56. const currentRoute = useRoute();
  57. const { title } = useGlobSetting();
  58. const handleNavClick = (item: { name: string; path: string }) => {
  59. if (!item.path) {
  60. router.replace({ name: 'StayTune' });
  61. // ElMessage.warning({ message: `${item.name}功能建设中,暂无法访问`, offset: 100, grouping: true });
  62. return;
  63. }
  64. activeNav.value = item.name;
  65. router.push(item.path);
  66. };
  67. const selectedKey = computed(() => {
  68. return currentRoute.matched[0]?.name;
  69. });
  70. </script>
  71. <style lang="scss" scoped>
  72. .header {
  73. display: flex;
  74. align-items: center;
  75. position: relative;
  76. width: 100%;
  77. height: 78cpx;
  78. background: url('assets/images/home/nav-bg@1X.png') no-repeat center center / cover;
  79. z-index: 2;
  80. &__nav {
  81. @include flex-center;
  82. gap: 20cpx;
  83. height: 100%;
  84. margin-left: 32cpx;
  85. &--item {
  86. @include flex-center;
  87. height: 45cpx;
  88. padding: 10cpx 20cpx;
  89. gap: 8cpx;
  90. font-size: 18cpx;
  91. color: #333;
  92. border-radius: 4cpx;
  93. cursor: pointer;
  94. border: 1px solid transparent;
  95. border-radius: 4px;
  96. // transition: all 0.3s ease-in-out;
  97. &.active,
  98. &:hover {
  99. background: linear-gradient(180deg, #33afff, $primary-color);
  100. color: $white-color;
  101. }
  102. }
  103. }
  104. }
  105. .header__logo {
  106. width: 34cpx;
  107. height: 34cpx;
  108. margin-left: 38cpx;
  109. }
  110. .platform-name {
  111. font-size: 18cpx;
  112. font-weight: 550;
  113. margin-left: 9cpx;
  114. }
  115. .platform__right {
  116. @include flex-center;
  117. position: absolute;
  118. top: 0;
  119. right: 0;
  120. height: 73cpx;
  121. &__search {
  122. @include flex-center;
  123. width: 210cpx;
  124. height: 100%;
  125. padding: 28cpx 26cpx;
  126. background: rgba($white-color, 0.4);
  127. }
  128. &__login {
  129. @include flex-center;
  130. gap: 10cpx;
  131. height: 100%;
  132. padding: 27cpx 40cpx 26cpx 40cpx;
  133. font-size: 18cpx;
  134. color: $primary-color;
  135. cursor: pointer;
  136. }
  137. }
  138. .input-with-icon {
  139. :deep(.el-input__wrapper),
  140. :deep(.el-input-group__prepend) {
  141. background-color: transparent;
  142. box-shadow: none;
  143. padding: 0;
  144. }
  145. :deep(.el-input__inner) {
  146. width: 120cpx;
  147. margin-left: 5cpx;
  148. font-size: 16cpx;
  149. color: #909399;
  150. }
  151. .search-icon {
  152. width: 28cpx;
  153. height: 28cpx;
  154. cursor: pointer;
  155. }
  156. }
  157. </style>