Header.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <header class="header" :class="{ 'header-hidden': isHidden }" role="banner">
  3. <div class="header-left">
  4. <a href="/" class="brand" aria-label="Home">
  5. <NuxtPicture src="/logo.png" alt="DDAC logo" class="brand-logo" width="34" height="34"></NuxtPicture>
  6. <h1 class="brand-title">DDAC</h1>
  7. </a>
  8. </div>
  9. <nav class="header-nav" role="navigation" aria-label="Main navigation">
  10. <NuxtLink to="/pc" class="nav-item">首页</NuxtLink>
  11. <NuxtLink to="/pc/products" class="nav-item">产品</NuxtLink>
  12. <NuxtLink to="/pc/solutions" class="nav-item">行业解决方案</NuxtLink>
  13. <NuxtLink to="/pc/docs" class="nav-item">文档中心</NuxtLink>
  14. <NuxtLink to="/pc/about" class="nav-item">了解我们</NuxtLink>
  15. </nav>
  16. <div class="header-right">
  17. <div>登录</div>
  18. <div class="register">注册</div>
  19. </div>
  20. </header>
  21. </template>
  22. <script setup>
  23. const { y: scrollY } = useWindowScroll()
  24. const lastScrollY = ref(0)
  25. const isHidden = ref(false)
  26. watchEffect(() => {
  27. if (scrollY.value > lastScrollY.value && scrollY.value > 60) {
  28. isHidden.value = true
  29. } else {
  30. isHidden.value = false
  31. }
  32. lastScrollY.value = scrollY.value
  33. })
  34. </script>
  35. <style lang="scss">
  36. .header {
  37. box-sizing: border-box;
  38. padding: 22px 0;
  39. display: flex;
  40. justify-content: space-between;
  41. align-items: center;
  42. position: fixed;
  43. top: 0;
  44. left: 0;
  45. right: 0;
  46. z-index: 1000;
  47. background: #030014;
  48. transition: transform 0.3s ease;
  49. &.header-hidden {
  50. transform: translateY(-100%);
  51. }
  52. }
  53. .header-left {
  54. flex: 1;
  55. display: flex;
  56. align-items: center;
  57. justify-content: right;
  58. .brand {
  59. display: flex;
  60. align-items: center;
  61. text-decoration: none;
  62. .brand-logo {
  63. margin-right: 8px;
  64. }
  65. .brand-title {
  66. color: #FFF;
  67. font-family: Roboto;
  68. font-size: 30px;
  69. font-style: normal;
  70. font-weight: 700;
  71. line-height: 36px;
  72. }
  73. }
  74. }
  75. .header-nav {
  76. flex: 2;
  77. display: flex;
  78. justify-content: center;
  79. align-items: center;
  80. .nav-item {
  81. text-decoration: none;
  82. margin: 0 15px;
  83. cursor: pointer;
  84. color: #FFF;
  85. font-family: "Source Han Sans CN";
  86. font-size: 14px;
  87. font-style: normal;
  88. font-weight: 400;
  89. line-height: 14px;
  90. &:hover {
  91. // color: #000;
  92. }
  93. }
  94. }
  95. .header-right {
  96. flex: 1;
  97. display: flex;
  98. align-items: center;
  99. justify-content: left;
  100. color: #FFF;
  101. div {
  102. margin-left: 20px;
  103. cursor: pointer;
  104. }
  105. .register {
  106. display: flex;
  107. width: 100px;
  108. height: 40px;
  109. justify-content: center;
  110. align-items: center;
  111. gap: 10px;
  112. border-radius: 10px;
  113. border: 1px solid #7D46FF;
  114. background: #030014;
  115. box-shadow: 0.5px 0.5px 18px 0 rgba(125, 70, 255, 0.45) inset;
  116. }
  117. }
  118. </style>