From 2361e2073dfeef61ce964b92129e57e6e46bd7e2 Mon Sep 17 00:00:00 2001 From: Frudrax Cheng Date: Mon, 13 Apr 2026 13:59:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=A7=E5=93=81=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E4=BA=8C=E7=BA=A7=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .astro/content.d.ts | 2 +- .astro/settings.json | 2 +- src/layouts/Layout.astro | 242 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 233 insertions(+), 13 deletions(-) diff --git a/.astro/content.d.ts b/.astro/content.d.ts index 96b2fc3..c0082cc 100644 --- a/.astro/content.d.ts +++ b/.astro/content.d.ts @@ -194,6 +194,6 @@ declare module 'astro:content' { LiveContentConfig['collections'][C]['loader'] >; - export type ContentConfig = typeof import("./../src/content.config.mjs"); + export type ContentConfig = typeof import("../src/content.config.mjs"); export type LiveContentConfig = never; } diff --git a/.astro/settings.json b/.astro/settings.json index 1151f3b..c267df2 100644 --- a/.astro/settings.json +++ b/.astro/settings.json @@ -1,5 +1,5 @@ { "_variables": { - "lastUpdateCheck": 1774419633747 + "lastUpdateCheck": 1776058818761 } } \ No newline at end of file diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 320eaee..e8137b2 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -4,24 +4,54 @@ import 'font-awesome/css/font-awesome.min.css'; const { title = "浙江贝凡网络科技", activeNav = "home" } = Astro.props; -const navItems = [ +interface NavChild { + id: string; + label: string; + href: string; + icon: string; +} + +interface NavItem { + id: string; + label: string; + href: string; + icon: string; + children?: NavChild[]; +} + +const navItems: NavItem[] = [ { id: 'home', label: '公司介绍', href: '/', icon: 'fa-building' }, - { id: 'qazk', label: '企安智控', href: '/qazk', icon: 'fa-cogs' }, + { + id: 'products', label: '产品中心', href: '/qazk', icon: 'fa-cubes', + children: [ + { id: 'qazk', label: '企安智控', href: '/qazk', icon: 'fa-cogs' }, + { id: 'elderly', label: '智慧养老', href: '/elderly', icon: 'fa-heartbeat' }, + { id: 'construction', label: '智慧工地', href: '/construction', icon: 'fa-industry' }, + { id: 'kitchen', label: '明厨亮灶', href: '/kitchen', icon: 'fa-cutlery' }, + { id: 'education', label: '学校教育', href: '/education', icon: 'fa-graduation-cap' }, + ] + }, { id: 'customization', label: '本地化定制', href: '/customization', icon: 'fa-wrench' }, { id: 'partnership', label: '生态合作', href: '/partnership', icon: 'fa-handshake-o' }, ]; -function getNavLinkClass(itemId: string) { +function isActive(item: NavItem): boolean { + if (item.id === activeNav) return true; + if (item.children) return item.children.some(child => child.id === activeNav); + return false; +} + +function getNavLinkClass(item: NavItem) { const baseClass = 'flex items-center gap-2 px-4 py-2.5 rounded-full font-medium transition-all duration-300'; - if (itemId === activeNav) { + if (isActive(item)) { return `${baseClass} bg-primary text-white shadow-md`; } return `${baseClass} text-gray-600 hover:text-primary hover:bg-primary/10`; } -function getMobileNavLinkClass(itemId: string) { +function getMobileNavLinkClass(item: NavItem) { const baseClass = 'flex flex-col items-center justify-center py-2 px-2 min-w-[4.5rem] rounded-xl transition-all duration-300'; - if (itemId === activeNav) { + if (isActive(item)) { return `${baseClass} bg-primary text-white`; } return `${baseClass} text-gray-600 hover:bg-primary/10`; @@ -41,10 +71,35 @@ function getMobileNavLinkClass(itemId: string) { 浙江贝凡 Logo -