Header.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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: transparent;
  48. // background: #030014;
  49. transition: transform 0.3s ease;
  50. &.header-hidden {
  51. transform: translateY(-100%);
  52. }
  53. }
  54. .header-left {
  55. flex: 1;
  56. display: flex;
  57. align-items: center;
  58. justify-content: right;
  59. .brand {
  60. display: flex;
  61. align-items: center;
  62. text-decoration: none;
  63. .brand-logo {
  64. margin-right: 8px;
  65. }
  66. .brand-title {
  67. color: #FFF;
  68. font-family: Roboto;
  69. font-size: 30px;
  70. font-style: normal;
  71. font-weight: 700;
  72. line-height: 36px;
  73. }
  74. }
  75. }
  76. .header-nav {
  77. flex: 2;
  78. display: flex;
  79. justify-content: center;
  80. align-items: center;
  81. .nav-item {
  82. text-decoration: none;
  83. margin: 0 15px;
  84. cursor: pointer;
  85. color: #FFF;
  86. font-family: "Source Han Sans CN";
  87. font-size: 14px;
  88. font-style: normal;
  89. font-weight: 400;
  90. line-height: 14px;
  91. &:hover {
  92. // color: #000;
  93. }
  94. }
  95. }
  96. .header-right {
  97. flex: 1;
  98. display: flex;
  99. align-items: center;
  100. justify-content: left;
  101. color: #FFF;
  102. div {
  103. margin-left: 20px;
  104. cursor: pointer;
  105. }
  106. .register {
  107. display: flex;
  108. width: 100px;
  109. height: 40px;
  110. justify-content: center;
  111. align-items: center;
  112. gap: 10px;
  113. border-radius: 10px;
  114. border: 1px solid #7D46FF;
  115. background: #030014;
  116. box-shadow: 0.5px 0.5px 18px 0 rgba(125, 70, 255, 0.45) inset;
  117. }
  118. }
  119. </style>