Header.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. width: 100%;
  85. box-sizing: border-box;
  86. }
  87. .mb-header-container {
  88. height: 44px;
  89. width: 100%;
  90. display: flex;
  91. justify-content: space-between;
  92. align-items: center;
  93. box-sizing: border-box;
  94. padding: 0 16px;
  95. }
  96. .brand {
  97. display: flex;
  98. align-items: center;
  99. text-decoration: none;
  100. .brand-logo {
  101. margin-right: 8px;
  102. }
  103. .brand-title {
  104. color: #FFF;
  105. font-size: 14px;
  106. font-weight: 700;
  107. }
  108. }
  109. .mb-header-right {
  110. display: flex;
  111. align-items: center;
  112. gap: 20px;
  113. color: #fff;
  114. }
  115. // Nav 展开动画
  116. .nav-expand-enter-active,
  117. .nav-expand-leave-active {
  118. overflow: hidden;
  119. transition: max-height 0.3s ease-out;
  120. }
  121. .nav-expand-enter-from,
  122. .nav-expand-leave-to {
  123. max-height: 0 !important;
  124. }
  125. .nav-expand-enter-to,
  126. .nav-expand-leave-from {
  127. max-height: 500px !important;
  128. }
  129. // 子菜单展开动画
  130. .submenu-expand-enter-active,
  131. .submenu-expand-leave-active {
  132. overflow: hidden;
  133. transition: max-height 0.25s ease-out;
  134. }
  135. .submenu-expand-enter-from,
  136. .submenu-expand-leave-to {
  137. max-height: 0 !important;
  138. }
  139. .submenu-expand-enter-to,
  140. .submenu-expand-leave-from {
  141. max-height: 300px !important;
  142. }
  143. .mobile-nav {
  144. background: #030014;
  145. border-top: 1px solid rgba(255, 255, 255, 0.1);
  146. max-height: 500px;
  147. }
  148. .nav-item {
  149. padding: 10px;
  150. color: #FFF;
  151. font-size: 16px;
  152. border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  153. cursor: pointer;
  154. &:last-of-type {
  155. border-bottom: none;
  156. }
  157. a {
  158. color: inherit;
  159. text-decoration: none;
  160. display: block;
  161. }
  162. }
  163. .nav-item-wrapper {
  164. border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  165. .nav-item {
  166. border-bottom: none;
  167. }
  168. &:last-of-type {
  169. border-bottom: none;
  170. }
  171. }
  172. .nav-item-icon {
  173. transition: transform 0.3s ease;
  174. float: right;
  175. }
  176. .icon-rotated {
  177. transform: rotate(180deg);
  178. }
  179. .dropdown-menu {
  180. background: rgba(63, 63, 63, 0.60);
  181. max-height: 300px;
  182. overflow: hidden;
  183. padding: 0;
  184. }
  185. .dropdown-item {
  186. padding: 8px 10px 8px 24px;
  187. display: flex;
  188. align-items: center;
  189. color: #bdbdbd;
  190. text-decoration: none;
  191. font-size: 14px;
  192. transition: color 0.2s;
  193. gap: 12px;
  194. white-space: nowrap;
  195. &:hover {
  196. background: transparent;
  197. color: #ffffff;
  198. }
  199. .item-img {
  200. width: 20px;
  201. height: 20px;
  202. flex-shrink: 0;
  203. opacity: 0.8;
  204. }
  205. &:hover .item-img {
  206. opacity: 1;
  207. }
  208. p {
  209. color: inherit;
  210. font-size: 14px;
  211. font-weight: 400;
  212. margin: 0;
  213. white-space: nowrap;
  214. }
  215. }
  216. </style>