AppHeader.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <script setup>
  2. import { computed, ref, watch } from "vue";
  3. import { RouterLink, useRoute } from "vue-router";
  4. import { Icon } from "@iconify/vue";
  5. const route = useRoute();
  6. const mobileOpen = ref(false);
  7. const navItems = [
  8. { label: "产品", to: "/products" },
  9. { label: "解决方案", to: "/solutions" },
  10. { label: "客户案例", to: "/cases" },
  11. { label: "新闻动态", to: "/news" },
  12. ];
  13. watch(
  14. () => route.fullPath,
  15. () => {
  16. mobileOpen.value = false;
  17. },
  18. );
  19. const mobileLabel = computed(() =>
  20. mobileOpen.value ? "关闭菜单" : "打开菜单",
  21. );
  22. </script>
  23. <template>
  24. <header class="app-header">
  25. <div class="app-header__inner">
  26. <div style="display: flex; align-items: center">
  27. <RouterLink class="brand" to="/" aria-label="工业互联网门户">
  28. <img
  29. src="../../assets//images/logo.png"
  30. alt=""
  31. style="width: auto; height: 36px"
  32. />
  33. </RouterLink>
  34. <nav class="nav" aria-label="主导航">
  35. <RouterLink
  36. v-for="item in navItems"
  37. :key="item.to"
  38. class="nav__link"
  39. :to="item.to"
  40. >
  41. {{ item.label }}
  42. </RouterLink>
  43. </nav>
  44. </div>
  45. <div class="actions">
  46. <RouterLink class="btn actions__login" to="/contact">登录</RouterLink>
  47. <RouterLink class="btn btn-primary" to="/contact">免费注册</RouterLink>
  48. <button
  49. class="hamburger"
  50. type="button"
  51. :aria-label="mobileLabel"
  52. :aria-expanded="mobileOpen ? 'true' : 'false'"
  53. @click="mobileOpen = !mobileOpen"
  54. >
  55. <Icon icon="lucide:menu" width="24" height="24" />
  56. </button>
  57. </div>
  58. </div>
  59. <div v-if="mobileOpen" class="mobile">
  60. <div class="mobile__inner container">
  61. <RouterLink
  62. v-for="item in navItems"
  63. :key="item.to"
  64. class="mobile__link"
  65. :to="item.to"
  66. >
  67. {{ item.label }}
  68. </RouterLink>
  69. <div class="divider"></div>
  70. <RouterLink class="mobile__link" to="/contact">联系咨询</RouterLink>
  71. </div>
  72. </div>
  73. </header>
  74. </template>
  75. <style scoped>
  76. .app-header {
  77. position: fixed;
  78. z-index: 50;
  79. top: 0;
  80. left: 0;
  81. right: 0;
  82. height: var(--header-h);
  83. background: rgba(255, 255, 255, 0.86);
  84. backdrop-filter: blur(14px);
  85. border-bottom: none;
  86. box-shadow: 0 12px 20px rgba(15, 23, 42, 0.05);
  87. }
  88. .app-header__inner {
  89. height: var(--header-h);
  90. display: flex;
  91. align-items: center;
  92. justify-content: space-between;
  93. gap: 18px;
  94. padding: 0 20px;
  95. }
  96. .brand {
  97. display: inline-flex;
  98. align-items: center;
  99. gap: 12px;
  100. min-width: 240px;
  101. }
  102. .brand__mark {
  103. width: 34px;
  104. height: 34px;
  105. border-radius: 10px;
  106. background: radial-gradient(
  107. circle at 30% 30%,
  108. var(--brand-200),
  109. var(--brand-600)
  110. );
  111. box-shadow: 0 12px 20px rgba(29, 78, 216, 0.22);
  112. }
  113. .brand__text {
  114. display: grid;
  115. line-height: 1.1;
  116. }
  117. .brand__name {
  118. font-weight: 800;
  119. letter-spacing: -0.02em;
  120. }
  121. .brand__tag {
  122. font-size: 12px;
  123. }
  124. .nav {
  125. display: flex;
  126. align-items: center;
  127. justify-content: center;
  128. gap: 2px;
  129. }
  130. .nav__link {
  131. padding: 10px 12px;
  132. border-radius: 10px;
  133. color: var(--slate-700);
  134. font-size: 18px;
  135. }
  136. .nav__link:hover {
  137. color: #1d4ed8;
  138. }
  139. .nav__link.router-link-exact-active {
  140. color: var(--brand-700);
  141. }
  142. .actions {
  143. display: inline-flex;
  144. align-items: center;
  145. justify-content: flex-end;
  146. gap: 10px;
  147. }
  148. .hamburger {
  149. display: none;
  150. width: 42px;
  151. height: 42px;
  152. border-radius: 12px;
  153. border: 1px solid var(--border);
  154. background: #fff;
  155. cursor: pointer;
  156. }
  157. .hamburger > span {
  158. display: block;
  159. height: 2px;
  160. background: var(--slate-700);
  161. margin: 5px 10px;
  162. border-radius: 2px;
  163. }
  164. .mobile {
  165. border-bottom: 1px solid var(--border);
  166. background: #fff;
  167. }
  168. .mobile__inner {
  169. padding: 14px 0 18px;
  170. display: grid;
  171. gap: 8px;
  172. }
  173. .mobile__link {
  174. padding: 10px 12px;
  175. border-radius: 12px;
  176. border: 1px solid var(--border);
  177. font-weight: 650;
  178. }
  179. .mobile__link.router-link-exact-active {
  180. border-color: rgba(37, 99, 235, 0.35);
  181. background: rgba(37, 99, 235, 0.08);
  182. color: var(--brand-700);
  183. }
  184. @media (max-width: 1024px) {
  185. .brand {
  186. min-width: auto;
  187. }
  188. .nav {
  189. display: none;
  190. }
  191. .actions__login {
  192. display: none;
  193. }
  194. .actions__cta {
  195. display: none;
  196. }
  197. .hamburger {
  198. display: inline-block;
  199. }
  200. }
  201. </style>