NavBar.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <!-- 移动端菜单 -->
  3. <div class="mobile-menu">
  4. <IconMenu
  5. :openState="mobileMenuShow"
  6. @click="mobileMenuShow = !mobileMenuShow"
  7. />
  8. <Teleport to="body">
  9. <div
  10. v-show="mobileMenuShow"
  11. :class="[
  12. 'mobile-menu-popover',
  13. mobileMenuShow ? 'visible' : '',
  14. ]"
  15. @click="mobileMenuShow=false"
  16. >
  17. <div>
  18. <RouterLink to="/">首页</RouterLink>
  19. <RouterLink to="/about">保护区概况</RouterLink>
  20. <RouterLink to="/news">资讯动态</RouterLink>
  21. <RouterLink to="/introduction">文化常识</RouterLink>
  22. <RouterLink to="/inheritor">保护传承</RouterLink>
  23. <RouterLink to="/communicate">传播交流</RouterLink>
  24. <RouterLink to="/introduction/policy">政策法规</RouterLink>
  25. <RouterLink to="/research">理论研究</RouterLink>
  26. <RouterLink to="/fusion">文旅融合</RouterLink>
  27. </div>
  28. </div>
  29. </Teleport>
  30. </div>
  31. <!-- 导航栏 -->
  32. <nav
  33. :class="[
  34. 'main',
  35. headerBlur ? 'need-blur' : '',
  36. scrollValue > 200 ? 'nav-scrolled' : 'nav-not-scrolled',
  37. ]"
  38. >
  39. <div></div>
  40. <div class="group">
  41. <div class="link-placeholder" />
  42. <RouterLink to="/">首页</RouterLink>
  43. <RouterLink to="/about">保护区概况</RouterLink>
  44. <RouterLink to="/news">资讯动态</RouterLink>
  45. <RouterLink to="/introduction">文化常识</RouterLink>
  46. </div>
  47. <div class="group center">
  48. <div class="headerlogos">
  49. <img class="main-clickable" src="https://mn.wenlvti.net/app_static/minnan/logo-large-light.png" @click="goIndex" />
  50. <div>
  51. <p class="large">世界闽南文化交流中心</p>
  52. <p>闽南文化生态保护区<span>(厦门市)</span></p>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="group">
  57. <RouterLink to="/inheritor">保护传承</RouterLink>
  58. <RouterLink to="/communicate">传播交流</RouterLink>
  59. <RouterLink to="/introduction/policy">政策法规</RouterLink>
  60. <RouterLink to="/research">理论研究</RouterLink>
  61. <RouterLink to="/fusion">文旅融合</RouterLink>
  62. </div>
  63. <div></div>
  64. </nav>
  65. </template>
  66. <script setup lang="ts">
  67. import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
  68. import { useRoute, useRouter } from 'vue-router';
  69. import IconMenu from './icons/IconMenu.vue';
  70. const router = useRouter();
  71. const route = useRoute();
  72. const scrollValue = ref(0);
  73. const mobileMenuShow = ref(false);
  74. const headerBlur = computed(() => {
  75. return route.name != 'home';
  76. });
  77. function goIndex() {
  78. router.push({ path: '/' });
  79. }
  80. function onScroll() {
  81. scrollValue.value = window.scrollY;
  82. }
  83. onMounted(() => {
  84. window.addEventListener('scroll', onScroll);
  85. });
  86. onBeforeUnmount(() => {
  87. window.removeEventListener('scroll', onScroll);
  88. });
  89. </script>
  90. <style lang="scss">
  91. @use '@/assets/scss/colors.scss' as *;
  92. $nav-height: 70px;
  93. $nav-color: $primary-color;
  94. $nav-text-color: $text-color-light;
  95. .nav-placeholder {
  96. height: $nav-height;
  97. background-color: $nav-color;
  98. }
  99. nav.main {
  100. position: fixed;
  101. display: flex;
  102. justify-content: space-around;
  103. align-items: center;
  104. z-index: 100;
  105. width: 100%;
  106. top: 0;
  107. height: $nav-height;
  108. background-color: $nav-color;
  109. border-bottom: 1px solid rgba(#fff, 0.2);
  110. color: $nav-text-color;
  111. transition: all ease-in-out 0.3s;
  112. &.nav-scrolled {
  113. background-color: $nav-color;
  114. }
  115. &.need-blur.nav-not-scrolled {
  116. //background-color: transparent;
  117. backdrop-filter: blur(10px);
  118. }
  119. a {
  120. color: rgba($nav-text-color, 0.8);
  121. text-align: center;
  122. text-decoration: none;
  123. &:focus {
  124. outline: none;
  125. }
  126. &.router-link-active, &.router-link-exact-active, &:hover {
  127. color: $nav-text-color;
  128. }
  129. &.router-link-exact-active {
  130. font-weight: bold;
  131. }
  132. }
  133. .group {
  134. display: flex;
  135. gap: 1rem;
  136. a, .link-placeholder {
  137. width: 100px;
  138. height: $nav-height;
  139. line-height: $nav-height;
  140. }
  141. }
  142. .headerlogos {
  143. display: flex;
  144. flex-direction: row;
  145. align-items: center;
  146. img {
  147. width: 95px;
  148. height: 55px;
  149. margin-right: 10px;
  150. }
  151. > div {
  152. display: flex;
  153. flex-direction: column;
  154. justify-content: center;
  155. font-family: nzgrRuyinZouZhangKai;
  156. margin-bottom: 6px;
  157. p {
  158. margin: 0;
  159. font-size: 1rem;
  160. height: 20px;
  161. letter-spacing: 0.15rem;
  162. span {
  163. font-size: 1rem;
  164. margin-left: 10px;
  165. }
  166. &.large {
  167. height: 33px;
  168. font-size: 1.6rem;
  169. letter-spacing: -0.1rem;
  170. }
  171. }
  172. }
  173. }
  174. }
  175. .mobile-menu {
  176. display: none;
  177. position: fixed;
  178. left: 25px;
  179. top: 20px;
  180. z-index: 120;
  181. width: 30px;
  182. height: 30px;
  183. color: $text-color-light;
  184. }
  185. .mobile-menu-popover {
  186. position: fixed;
  187. top: 0;
  188. bottom: 0;
  189. left: 0;
  190. right: 0;
  191. background-color: $box-color;
  192. border-bottom: $border-grey-color;
  193. color: $text-color;
  194. z-index: 101;
  195. background-color: rgba(#000, 0.1);
  196. > div {
  197. display: flex;
  198. flex-direction: column;
  199. padding-top: $nav-height;
  200. height: 100%;
  201. width: 190px;
  202. text-align: center;
  203. background-color: #FBF8F3;
  204. }
  205. font-family: SourceHanSerifCNBold;
  206. animation: mobile-menu-popover-fade 0.3s ease-in-out;
  207. a {
  208. line-height: 40px;
  209. height: 40px;
  210. width: 100%;
  211. color: $text-color;
  212. }
  213. &.visible {
  214. display: flex;
  215. }
  216. }
  217. @media (max-width: 1460px) {
  218. nav.main {
  219. .group {
  220. gap: 0.5rem;
  221. a {
  222. width: 80px;
  223. }
  224. }
  225. .headerlogos > div {
  226. display: none;
  227. }
  228. }
  229. }
  230. @media (max-width: 1024px) {
  231. }
  232. @media (max-width: 768px) {
  233. nav.main {
  234. justify-content: space-between;
  235. padding: 0 30px;
  236. .group:not(.center) {
  237. display: none;
  238. }
  239. .headerlogos > div {
  240. display: initial;
  241. }
  242. }
  243. .mobile-menu {
  244. display: block;
  245. }
  246. }
  247. @media (max-width: 550px) {
  248. nav.main {
  249. .headerlogos {
  250. img {
  251. width: 55px;
  252. height: 35px;
  253. margin-right: 7px;
  254. }
  255. > div {
  256. display: initial;
  257. margin-bottom: 0;
  258. p {
  259. font-size: 0.7rem;
  260. height: 20px;
  261. span {
  262. font-size: 0.7rem;
  263. margin-left: 10px;
  264. }
  265. &.large {
  266. height: 23px;
  267. font-size: 1.4rem;
  268. letter-spacing: -0.1rem;
  269. }
  270. }
  271. }
  272. }
  273. }
  274. }
  275. @media (max-width: 388px) {
  276. nav.main {
  277. .headerlogos > div {
  278. display: none;
  279. }
  280. }
  281. }
  282. @keyframes mobile-menu-popover-fade {
  283. 0% { opacity: 0; transform: translateX(-100px); }
  284. 100% { opacity: 1; transform: translateX(0); }
  285. }
  286. </style>