Header.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <header class="mb-header">
  3. <div class="mb-header-container">
  4. <a href="/mobile" class="brand">
  5. <NuxtImg src="/logo.png" alt="DDAC logo" class="brand-logo" width="14" height="14" />
  6. <h1 class="brand-title">DDAC</h1>
  7. </a>
  8. <div class="mb-header-right">
  9. <Icon name="lineicons:magnifier" size="20" />
  10. <Icon name="material-symbols:account-circle-full" size="20" />
  11. <Icon @click="toggleMenu" name="material-symbols:menu-rounded" size="20" />
  12. </div>
  13. </div>
  14. <Transition name="nav-expand">
  15. <nav v-show="isMenuOpen" class="mobile-nav">
  16. <div class="nav-item">
  17. <NuxtLink to="/mobile" @click="closeMenu">首页</NuxtLink>
  18. </div>
  19. <div class="nav-item-wrapper">
  20. <div class="nav-item" @click="toggleProducts">
  21. <span>产品</span>
  22. <Icon name="line-md:chevron-down" class="nav-item-icon" :class="{ 'icon-rotated': isProductsOpen }" />
  23. </div>
  24. <Transition name="submenu-expand">
  25. <div v-show="isProductsOpen" class="dropdown-menu">
  26. <NuxtLink to="/mobile/products/sdk" class="dropdown-item" @click="closeMenu">
  27. <img class="item-img" src="~/assets/svg/header/icon1.svg" alt="SDK 安全加固">
  28. <p>SDK 安全加固</p>
  29. </NuxtLink>
  30. <NuxtLink to="/mobile/products/web" class="dropdown-item" @click="closeMenu">
  31. <img class="item-img" src="~/assets/svg/header/icon2.svg" alt="Web 安全加速">
  32. <p>Web 安全加速</p>
  33. </NuxtLink>
  34. <NuxtLink to="/mobile/products/dns" class="dropdown-item" @click="closeMenu">
  35. <img class="item-img" src="~/assets/svg/header/icon3.svg" alt="DNS 全球解析">
  36. <p>DNS 全球解析</p>
  37. </NuxtLink>
  38. <NuxtLink to="/mobile/products/boost" class="dropdown-item" @click="closeMenu">
  39. <img class="item-img" src="~/assets/svg/header/icon4.svg" alt="高防服务器">
  40. <p>高防服务器</p>
  41. </NuxtLink>
  42. </div>
  43. </Transition>
  44. </div>
  45. <div class="nav-item">
  46. <NuxtLink to="/mobile/solutions" @click="closeMenu">行业解决方案</NuxtLink>
  47. </div>
  48. <div class="nav-item">
  49. <NuxtLink to="/mobile/docs" @click="closeMenu">文档中心</NuxtLink>
  50. </div>
  51. <div class="nav-item">
  52. <NuxtLink to="/mobile/about" @click="closeMenu">了解我们</NuxtLink>
  53. </div>
  54. </nav>
  55. </Transition>
  56. </header>
  57. </template>
  58. <script setup>
  59. const isMenuOpen = ref(false)
  60. const isProductsOpen = ref(false)
  61. const toggleMenu = () => {
  62. isMenuOpen.value = !isMenuOpen.value
  63. // 关闭菜单时也关闭产品子菜单
  64. if (!isMenuOpen.value) {
  65. isProductsOpen.value = false
  66. }
  67. }
  68. const closeMenu = () => {
  69. isMenuOpen.value = false
  70. isProductsOpen.value = false
  71. }
  72. const toggleProducts = () => {
  73. isProductsOpen.value = !isProductsOpen.value
  74. }
  75. </script>
  76. <style lang="scss" scoped>
  77. .mb-header {
  78. position: fixed;
  79. top: 0;
  80. left: 0;
  81. right: 0;
  82. z-index: 1000;
  83. background: #030014;
  84. border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  85. width: 100%;
  86. box-sizing: border-box;
  87. }
  88. .mb-header-container {
  89. height: 44px;
  90. width: 100%;
  91. display: flex;
  92. justify-content: space-between;
  93. align-items: center;
  94. box-sizing: border-box;
  95. padding: 0 16px;
  96. }
  97. .brand {
  98. display: flex;
  99. align-items: center;
  100. text-decoration: none;
  101. .brand-logo {
  102. margin-right: 8px;
  103. }
  104. .brand-title {
  105. color: #FFF;
  106. font-size: 14px;
  107. font-weight: 700;
  108. }
  109. }
  110. .mb-header-right {
  111. display: flex;
  112. align-items: center;
  113. gap: 20px;
  114. color: #fff;
  115. }
  116. // Nav 展开动画
  117. .nav-expand-enter-active,
  118. .nav-expand-leave-active {
  119. overflow: hidden;
  120. transition: max-height 0.3s ease-out;
  121. }
  122. .nav-expand-enter-from,
  123. .nav-expand-leave-to {
  124. max-height: 0 !important;
  125. }
  126. .nav-expand-enter-to,
  127. .nav-expand-leave-from {
  128. max-height: 500px !important;
  129. }
  130. // 子菜单展开动画
  131. .submenu-expand-enter-active,
  132. .submenu-expand-leave-active {
  133. overflow: hidden;
  134. transition: max-height 0.25s ease-out;
  135. }
  136. .submenu-expand-enter-from,
  137. .submenu-expand-leave-to {
  138. max-height: 0 !important;
  139. }
  140. .submenu-expand-enter-to,
  141. .submenu-expand-leave-from {
  142. max-height: 300px !important;
  143. }
  144. .mobile-nav {
  145. background: #030014;
  146. border-top: 1px solid rgba(255, 255, 255, 0.1);
  147. max-height: 500px;
  148. }
  149. .nav-item {
  150. padding: 10px;
  151. color: #FFF;
  152. font-size: 16px;
  153. border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  154. cursor: pointer;
  155. &:last-of-type {
  156. border-bottom: none;
  157. }
  158. a {
  159. color: inherit;
  160. text-decoration: none;
  161. display: block;
  162. }
  163. }
  164. .nav-item-wrapper {
  165. border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  166. .nav-item {
  167. border-bottom: none;
  168. }
  169. &:last-of-type {
  170. border-bottom: none;
  171. }
  172. }
  173. .nav-item-icon {
  174. transition: transform 0.3s ease;
  175. float: right;
  176. }
  177. .icon-rotated {
  178. transform: rotate(180deg);
  179. }
  180. .dropdown-menu {
  181. background: rgba(63, 63, 63, 0.60);
  182. max-height: 300px;
  183. overflow: hidden;
  184. padding: 0;
  185. }
  186. .dropdown-item {
  187. padding: 8px 10px 8px 24px;
  188. display: flex;
  189. align-items: center;
  190. color: #bdbdbd;
  191. text-decoration: none;
  192. font-size: 14px;
  193. transition: color 0.2s;
  194. gap: 12px;
  195. white-space: nowrap;
  196. &:hover {
  197. background: transparent;
  198. color: #ffffff;
  199. }
  200. .item-img {
  201. width: 20px;
  202. height: 20px;
  203. flex-shrink: 0;
  204. opacity: 0.8;
  205. }
  206. &:hover .item-img {
  207. opacity: 1;
  208. }
  209. p {
  210. color: inherit;
  211. font-size: 14px;
  212. font-weight: 400;
  213. margin: 0;
  214. white-space: nowrap;
  215. }
  216. }
  217. </style>