| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- <script setup>
- import { computed, ref, watch } from "vue";
- import { RouterLink, useRoute } from "vue-router";
- import { Icon } from "@iconify/vue";
- const route = useRoute();
- const mobileOpen = ref(false);
- const navItems = [
- { label: "产品", to: "/products" },
- { label: "解决方案", to: "/solutions" },
- { label: "客户案例", to: "/cases" },
- { label: "新闻动态", to: "/news" },
- ];
- watch(
- () => route.fullPath,
- () => {
- mobileOpen.value = false;
- },
- );
- const mobileLabel = computed(() =>
- mobileOpen.value ? "关闭菜单" : "打开菜单",
- );
- </script>
- <template>
- <header class="app-header">
- <div class="app-header__inner">
- <div style="display: flex; align-items: center">
- <RouterLink class="brand" to="/" aria-label="工业互联网门户">
- <img
- src="../../assets//images/logo.png"
- alt=""
- style="width: auto; height: 36px"
- />
- </RouterLink>
- <nav class="nav" aria-label="主导航">
- <RouterLink
- v-for="item in navItems"
- :key="item.to"
- class="nav__link"
- :to="item.to"
- >
- {{ item.label }}
- </RouterLink>
- </nav>
- </div>
- <div class="actions">
- <RouterLink class="btn actions__login" to="/contact">登录</RouterLink>
- <RouterLink class="btn btn-primary" to="/contact">免费注册</RouterLink>
- <button
- class="hamburger"
- type="button"
- :aria-label="mobileLabel"
- :aria-expanded="mobileOpen ? 'true' : 'false'"
- @click="mobileOpen = !mobileOpen"
- >
- <Icon icon="lucide:menu" width="24" height="24" />
- </button>
- </div>
- </div>
- <div v-if="mobileOpen" class="mobile">
- <div class="mobile__inner container">
- <RouterLink
- v-for="item in navItems"
- :key="item.to"
- class="mobile__link"
- :to="item.to"
- >
- {{ item.label }}
- </RouterLink>
- <div class="divider"></div>
- <RouterLink class="mobile__link" to="/contact">联系咨询</RouterLink>
- </div>
- </div>
- </header>
- </template>
- <style scoped>
- .app-header {
- position: fixed;
- z-index: 50;
- top: 0;
- left: 0;
- right: 0;
- height: var(--header-h);
- background: rgba(255, 255, 255, 0.86);
- backdrop-filter: blur(14px);
- border-bottom: none;
- box-shadow: 0 12px 20px rgba(15, 23, 42, 0.05);
- }
- .app-header__inner {
- height: var(--header-h);
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 18px;
- padding: 0 20px;
- }
- .brand {
- display: inline-flex;
- align-items: center;
- gap: 12px;
- min-width: 240px;
- }
- .brand__mark {
- width: 34px;
- height: 34px;
- border-radius: 10px;
- background: radial-gradient(
- circle at 30% 30%,
- var(--brand-200),
- var(--brand-600)
- );
- box-shadow: 0 12px 20px rgba(29, 78, 216, 0.22);
- }
- .brand__text {
- display: grid;
- line-height: 1.1;
- }
- .brand__name {
- font-weight: 800;
- letter-spacing: -0.02em;
- }
- .brand__tag {
- font-size: 12px;
- }
- .nav {
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 2px;
- }
- .nav__link {
- padding: 10px 12px;
- border-radius: 10px;
- color: var(--slate-700);
- font-size: 18px;
- }
- .nav__link:hover {
- color: #1d4ed8;
- }
- .nav__link.router-link-exact-active {
- color: var(--brand-700);
- }
- .actions {
- display: inline-flex;
- align-items: center;
- justify-content: flex-end;
- gap: 10px;
- }
- .hamburger {
- display: none;
- width: 42px;
- height: 42px;
- border-radius: 12px;
- border: 1px solid var(--border);
- background: #fff;
- cursor: pointer;
- }
- .hamburger > span {
- display: block;
- height: 2px;
- background: var(--slate-700);
- margin: 5px 10px;
- border-radius: 2px;
- }
- .mobile {
- border-bottom: 1px solid var(--border);
- background: #fff;
- }
- .mobile__inner {
- padding: 14px 0 18px;
- display: grid;
- gap: 8px;
- }
- .mobile__link {
- padding: 10px 12px;
- border-radius: 12px;
- border: 1px solid var(--border);
- font-weight: 650;
- }
- .mobile__link.router-link-exact-active {
- border-color: rgba(37, 99, 235, 0.35);
- background: rgba(37, 99, 235, 0.08);
- color: var(--brand-700);
- }
- @media (max-width: 1024px) {
- .brand {
- min-width: auto;
- }
- .nav {
- display: none;
- }
- .actions__login {
- display: none;
- }
- .actions__cta {
- display: none;
- }
- .hamburger {
- display: inline-block;
- }
- }
- </style>
|