Header.vue 5.6 KB

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