feat(ui): 营销站 UI/UE/UX 治理 P0→P3 收官

复评(impeccable critique)全部 Priority Issues 与 Minor Observations 落地:
- P0 数字口径:MetricsBasisNote 单一真源 + metrics-basis.test fs 防线,接入
  products/solutions/services/home/about;纯渲染端加角注,不动 DB/seed 值
- P1 转化断头路:敬请期待态 + 404 语境出口 + services 空态双出口
- P1 首页并卡:TrustSection 早鸟横幅并入 CasesSection 单张深色共创卡
- P2 CTA 治理:CONSULT_CTA_ALLOWLIST 白名单 + 逐字符扫描器,/contact CTA 全归一
- P3 polish:footer 补 服务/公司列、contact 死三元/空槽/toast、GlobalErrorTracker 幂等日志
- 文档同源:PRODUCT/CONTEXT 动效带统一 180–280ms;DESIGN.md 立 The 10px Floor;
  font-floor.test 守卫禁止再引入 <10px(保留 10/11px 有意 Bain 微标签)

Gates: type-check 0 · jest 1581/132 · lint 0e/126w · contrast 7/7 · headings 10/10
This commit is contained in:
zhangxiang committed 2026-09-20 11:50:58 +08:00
1 parent dcf8ed6f20
commit f8917d4fda
66 files changed
+1448 -1313

No files matched your search

+29
View File
@@ -63,6 +63,16 @@ jest.mock('@/lib/site-config', () => ({
],
},
],
services: [
{
id: 'professional-services',
title: '专业服务',
items: [
{ id: 'consulting', title: '战略咨询', description: '数字化转型咨询规划', href: '/services/consulting' },
{ id: 'software', title: '企业软件', description: 'ERP/CRM/BI 系统实施', href: '/services/software' },
],
},
],
},
}),
SiteConfigProvider: ({ children }: { children: React.ReactNode }) => <>{children}</>,
@@ -155,6 +165,25 @@ describe('Footer', () => {
expect(screen.getByText('零售业')).toBeInTheDocument();
});
it('should render services column from megaDropdown.services (P3 footer)', () => {
render(<Footer />);
expect(screen.getByTestId('card-services')).toBeInTheDocument();
expect(screen.getByText('服务', { exact: true })).toBeInTheDocument();
expect(screen.getByText('战略咨询')).toBeInTheDocument();
expect(screen.getByText('企业软件')).toBeInTheDocument();
});
it('should render company column with verified routes (P3 footer)', () => {
render(<Footer />);
const company = screen.getByTestId('card-company');
expect(company).toBeInTheDocument();
expect(screen.getByText('公司', { exact: true })).toBeInTheDocument();
expect(screen.getByText('关于我们').closest('a')).toHaveAttribute('href', '/about');
expect(screen.getByText('方法论').closest('a')).toHaveAttribute('href', '/methodology');
expect(screen.getByText('案例').closest('a')).toHaveAttribute('href', '/cases');
expect(screen.getByText('新闻动态').closest('a')).toHaveAttribute('href', '/news');
});
it('should render contact details', () => {
render(<Footer />);
expect(screen.getByText('contact@novalon.cn')).toBeInTheDocument();
+106 -60
View File
@@ -5,6 +5,14 @@ import Image from 'next/image';
import { Mail, MapPin } from 'lucide-react';
import { useSiteConfig } from '@/lib/site-config';
// 公司栏目为固定信息架构,路由均已验证存在(/about · /methodology · /cases · /news),与 NAVIGATION_V2 对齐。
const COMPANY_LINKS: ReadonlyArray<{ id: string; label: string; href: string }> = [
{ id: 'about', label: '关于我们', href: '/about' },
{ id: 'methodology', label: '方法论', href: '/methodology' },
{ id: 'cases', label: '案例', href: '/cases' },
{ id: 'news', label: '新闻动态', href: '/news' },
];
export function Footer() {
const config = useSiteConfig();
const productItems = (config.megaDropdown.products ?? [])
@@ -12,13 +20,18 @@ export function Footer() {
.filter(item => item.href !== '#');
const solutionItems = (config.megaDropdown.solutions ?? [])
.flatMap(group => group.items);
.flatMap(group => group.items)
.filter(item => item.href !== '#');
const serviceItems = (config.megaDropdown.services ?? [])
.flatMap(group => group.items)
.filter(item => item.href !== '#');
return (
<footer className="bg-dark-bg text-white relative overflow-hidden [&_a]:inline-flex [&_a]:items-center [&_a]:min-h-6" data-testid="footer" role="contentinfo">
<footer className="bg-dark-bg text-dark-text-primary relative overflow-hidden [&_a]:inline-flex [&_a]:items-center [&_a]:min-h-6" data-testid="footer" role="contentinfo">
<div className="max-w-container mx-auto px-4 sm:px-6 lg:px-10">
<div className="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-12 gap-10 lg:gap-12 py-16 lg:py-20">
<div data-testid="card-brand" className="col-span-2 lg:col-span-4">
<div data-testid="card-brand" className="col-span-2 md:col-span-4 lg:col-span-4">
<div className="mb-6">
<StaticLink href="/" className="inline-block group" aria-label="返回首页">
<Image
@@ -32,24 +45,70 @@ export function Footer() {
/>
</StaticLink>
</div>
<p className="text-gray-300 text-sm leading-relaxed max-w-md">
<p className="text-dark-text-secondary text-sm leading-relaxed max-w-md">
{config.slogan && (
<>
<span className="block text-gray-200 font-medium mb-2">{config.slogan}</span>
<span className="block text-dark-text-primary font-medium mb-2">{config.slogan}</span>
</>
)}
{config.description}
</p>
<div data-testid="card-contact" className="mt-8">
<div className="font-semibold text-sm mb-5 text-dark-text-primary tracking-widest uppercase">联系我们</div>
<ul className="space-y-4 mb-8 [&_li]:p-0 [&_li]:m-0 [&_li]:static [&_li::before]:hidden">
<li className="flex items-start gap-3">
<MapPin className="w-4 h-4 text-dark-text-muted mt-0.5 shrink-0" />
<span className="text-dark-text-secondary text-sm leading-relaxed">{config.address}</span>
</li>
<li className="flex items-start gap-3">
<Mail className="w-4 h-4 text-dark-text-muted mt-0.5 shrink-0" />
<a
href={`mailto:${config.email}`}
className="text-dark-text-secondary hover:text-dark-text-primary transition-colors duration-200 text-sm"
>
{config.email}
</a>
</li>
</ul>
<div className="flex gap-6">
<div>
<p className="text-xs text-dark-text-muted mb-3 tracking-wide">关注公众号</p>
<div className="inline-block p-2 border border-dark-border bg-dark-bg-secondary">
<Image
src="/images/qrcode.webp"
alt="微信公众号二维码"
width={96}
height={96}
className="w-24 h-24"
loading="lazy"
/>
</div>
</div>
<div>
<p className="text-xs text-dark-text-muted mb-3 tracking-wide">业务咨询</p>
<div className="inline-block p-2 border border-dark-border bg-dark-bg-secondary">
<Image
src="/images/wechat-business-qr.webp"
alt="业务咨询微信二维码"
width={96}
height={96}
className="w-24 h-24"
loading="lazy"
/>
</div>
</div>
</div>
</div>
</div>
<div data-testid="card-products" className="lg:col-span-2">
<div className="font-semibold text-sm mb-5 text-white tracking-widest uppercase">产品</div>
<div className="font-semibold text-sm mb-5 text-dark-text-primary tracking-widest uppercase">产品</div>
<ul className="space-y-3 [&_li]:p-0 [&_li]:m-0 [&_li]:static [&_li::before]:hidden">
{productItems.map((item) => (
<li key={item.id}>
<StaticLink
href={item.href}
className="text-gray-300 hover:text-white transition-colors duration-200 text-sm whitespace-nowrap"
className="text-dark-text-secondary hover:text-dark-text-primary transition-colors duration-200 text-sm whitespace-nowrap"
>
{item.title}
</StaticLink>
@@ -59,13 +118,13 @@ export function Footer() {
</div>
<div data-testid="card-solutions" className="lg:col-span-2">
<div className="font-semibold text-sm mb-5 text-white tracking-widest uppercase">解决方案</div>
<div className="font-semibold text-sm mb-5 text-dark-text-primary tracking-widest uppercase">解决方案</div>
<ul className="space-y-3 [&_li]:p-0 [&_li]:m-0 [&_li]:static [&_li::before]:hidden">
{solutionItems.map((item) => (
<li key={item.id}>
<StaticLink
href={item.href}
className="text-gray-300 hover:text-white transition-colors duration-200 text-sm whitespace-nowrap"
className="text-dark-text-secondary hover:text-dark-text-primary transition-colors duration-200 text-sm whitespace-nowrap"
>
{item.title}
</StaticLink>
@@ -74,64 +133,51 @@ export function Footer() {
</ul>
</div>
<div data-testid="card-contact" className="col-span-2 lg:col-span-4">
<div className="font-semibold text-sm mb-5 text-white tracking-widest uppercase">联系我们</div>
<ul className="space-y-4 mb-8 [&_li]:p-0 [&_li]:m-0 [&_li]:static [&_li::before]:hidden">
<li className="flex items-start gap-3">
<MapPin className="w-4 h-4 text-gray-400 mt-0.5 shrink-0" />
<span className="text-gray-300 text-sm leading-relaxed">{config.address}</span>
</li>
<li className="flex items-start gap-3">
<Mail className="w-4 h-4 text-gray-400 mt-0.5 shrink-0" />
<a
href={`mailto:${config.email}`}
className="text-gray-300 hover:text-white transition-colors duration-200 text-sm"
>
{config.email}
</a>
</li>
</ul>
<div className="flex gap-6">
<div>
<p className="text-xs text-gray-400 mb-3 tracking-wide">关注公众号</p>
<div className="inline-block p-2 border border-gray-800 bg-gray-900">
<Image
src="/images/qrcode.webp"
alt="微信公众号二维码"
width={96}
height={96}
className="w-24 h-24"
loading="lazy"
/>
</div>
</div>
<div>
<p className="text-xs text-gray-400 mb-3 tracking-wide">业务咨询</p>
<div className="inline-block p-2 border border-gray-800 bg-gray-900">
<Image
src="/images/wechat-business-qr.webp"
alt="业务咨询微信二维码"
width={96}
height={96}
className="w-24 h-24"
loading="lazy"
/>
</div>
</div>
{serviceItems.length > 0 && (
<div data-testid="card-services" className="lg:col-span-2">
<div className="font-semibold text-sm mb-5 text-dark-text-primary tracking-widest uppercase">服务</div>
<ul className="space-y-3 [&_li]:p-0 [&_li]:m-0 [&_li]:static [&_li::before]:hidden">
{serviceItems.map((item) => (
<li key={item.id}>
<StaticLink
href={item.href}
className="text-dark-text-secondary hover:text-dark-text-primary transition-colors duration-200 text-sm whitespace-nowrap"
>
{item.title}
</StaticLink>
</li>
))}
</ul>
</div>
)}
<div data-testid="card-company" className="lg:col-span-2">
<div className="font-semibold text-sm mb-5 text-dark-text-primary tracking-widest uppercase">公司</div>
<ul className="space-y-3 [&_li]:p-0 [&_li]:m-0 [&_li]:static [&_li::before]:hidden">
{COMPANY_LINKS.map((item) => (
<li key={item.id}>
<StaticLink
href={item.href}
className="text-dark-text-secondary hover:text-dark-text-primary transition-colors duration-200 text-sm whitespace-nowrap"
>
{item.label}
</StaticLink>
</li>
))}
</ul>
</div>
</div>
<div className="border-t border-gray-800 pt-6 pb-[calc(8rem+env(safe-area-inset-bottom,0px))] md:pb-8">
<div className="border-t border-dark-border pt-6 pb-[calc(8rem+env(safe-area-inset-bottom,0px))] md:pb-8">
<div className="flex flex-col md:flex-row justify-between items-start md:items-center gap-6 mb-6">
<p className="text-gray-300 text-xs">
<p className="text-dark-text-secondary text-xs">
© {new Date().getFullYear()} {config.name}. 版权所有.
</p>
<div className="flex gap-6">
<StaticLink href="/privacy" className="text-gray-300 hover:text-white text-xs transition-colors duration-200">
<StaticLink href="/privacy" className="text-dark-text-secondary hover:text-dark-text-primary text-xs transition-colors duration-200">
隐私政策
</StaticLink>
<StaticLink href="/terms" className="text-gray-300 hover:text-white text-xs transition-colors duration-200">
<StaticLink href="/terms" className="text-dark-text-secondary hover:text-dark-text-primary text-xs transition-colors duration-200">
服务条款
</StaticLink>
</div>
@@ -142,16 +188,16 @@ export function Footer() {
href="https://beian.miit.gov.cn/"
target="_blank"
rel="noopener noreferrer"
className="text-gray-300 hover:text-white transition-colors duration-200 inline-flex items-center"
className="text-dark-text-secondary hover:text-dark-text-primary transition-colors duration-200 inline-flex items-center"
>
{config.icp}
</a>
<span className="hidden sm:inline text-text-hint">|</span>
<span className="hidden sm:inline text-dark-text-muted">|</span>
<a
href="https://beian.mps.gov.cn/#/query/webSearch?code=51010602003285"
target="_blank"
rel="noreferrer"
className="text-gray-300 hover:text-white transition-colors duration-200 inline-flex items-center gap-1.5"
className="text-dark-text-secondary hover:text-dark-text-primary transition-colors duration-200 inline-flex items-center gap-1.5"
>
<Image
src="/images/beian-icon.png"
+8 -8
View File
@@ -51,10 +51,10 @@ function HeaderContent() {
const config = useSiteConfig();
const handleNavClick = useCallback((e: React.MouseEvent<HTMLAnchorElement>, item: NavigationItem) => {
e.preventDefault();
const handleNavClick = useCallback(() => {
// StaticLink 新契约:onClick 先于导航执行,不调 preventDefault 即由
// next/link 完成客户端跳转,此处只负责关闭抽屉。
setIsOpen(false);
window.location.href = item.href;
}, []);
const isActive = useCallback((item: NavigationItem) => {
@@ -138,7 +138,7 @@ function HeaderContent() {
<div key={item.id} className="relative -mx-2 px-2 py-2">
<StaticLink
href={item.href}
onClick={(e) => handleNavClick(e, item)}
onClick={handleNavClick}
className={cn(
'relative inline-flex items-center px-3 py-2 text-sm font-medium',
'transition-all duration-300 ease-out',
@@ -171,9 +171,9 @@ function HeaderContent() {
asChild
className=""
>
<StaticLink href="/contact" data-testid="consult-button" aria-label="立即咨询">
<StaticLink href="/contact" data-testid="consult-button" aria-label="预约咨询">
<MessageCircle className="w-4 h-4" />
<span className="hidden lg:inline">立即咨询</span>
<span className="hidden lg:inline">预约咨询</span>
<span className="lg:hidden" aria-hidden="true">咨询</span>
</StaticLink>
</Button>
@@ -231,7 +231,7 @@ function HeaderContent() {
>
<StaticLink
href={item.href}
onClick={(e) => handleNavClick(e, item)}
onClick={handleNavClick}
className={`
block px-4 py-4 text-base font-medium
transition-all duration-300 ease-out
@@ -254,7 +254,7 @@ function HeaderContent() {
>
<StaticLink href="/contact" onClick={() => setIsOpen(false)}>
<MessageCircle className="w-4 h-4" />
咨询专家
预约咨询
</StaticLink>
</Button>
</div>
-234
View File
@@ -1,234 +0,0 @@
import { describe, it, expect, beforeEach, jest } from '@jest/globals';
import { render, screen, fireEvent } from '@testing-library/react';
import '@testing-library/jest-dom';
import { MobileMenu } from './mobile-menu';
jest.mock('@/hooks/use-focus-trap', () => ({
useFocusTrap: () => ({ current: null }),
}));
jest.mock('@/lib/site-config', () => ({
useSiteConfig: () => ({
mainNav: [
{ id: 'products', label: '产品', href: '/products', hasDropdown: true, dropdownKey: 'products' },
{ id: 'solutions', label: '解决方案', href: '/solutions', hasDropdown: true, dropdownKey: 'solutions' },
{ id: 'services', label: '服务', href: '/services' },
{ id: 'about', label: '关于我们', href: '/about' },
{ id: 'contact', label: '联系我们', href: '/contact' },
],
megaDropdown: {
products: [
{ id: 'erp', title: 'ERP 管理系统', description: '财务·采购·销售·库存·生产', href: '/products/erp' },
],
solutions: [
{ id: 'manufacturing', title: '制造业', description: '智能制造·MES·质量管控', href: '/solutions/manufacturing' },
],
},
}),
SiteConfigProvider: ({ children }: { children: React.ReactNode }) => <>{children}</>,
}));
jest.mock('@/lib/constants', () => ({
NAVIGATION_V2: [
{ id: 'products', label: '产品', href: '/products', hasDropdown: true, dropdownKey: 'products' },
{ id: 'solutions', label: '解决方案', href: '/solutions', hasDropdown: true, dropdownKey: 'solutions' },
{ id: 'services', label: '服务', href: '/services' },
{ id: 'about', label: '关于我们', href: '/about' },
{ id: 'contact', label: '联系我们', href: '/contact' },
],
MEGA_DROPDOWN_DATA: {
products: [
{ id: 'erp', title: 'ERP 管理系统', description: '财务·采购·销售·库存·生产', href: '/products/erp' },
],
solutions: [
{ id: 'manufacturing', title: '制造业', description: '智能制造·MES·质量管控', href: '/solutions/manufacturing' },
],
},
}));
jest.mock('next/link', () => {
const MockLink = ({ children, href, ...props }: { children: React.ReactNode; href: string; [key: string]: unknown }) => (
<a href={href} {...props}>{children}</a>
);
MockLink.displayName = 'MockLink';
return MockLink;
});
jest.mock('framer-motion', () => ({
AnimatePresence: ({ children }: { children: React.ReactNode }) => <>{children}</>,
motion: {
div: ({ children, className, ...props }: { children: React.ReactNode; className?: string; [key: string]: unknown }) => (
<div className={className} {...props}>{children}</div>
),
},
}));
jest.mock('lucide-react', () => ({
ChevronDown: () => <span data-testid="chevron-down" />,
Menu: () => <span data-testid="menu-icon" />,
X: () => <span data-testid="x-icon" />,
}));
jest.mock('@/components/ui/static-link', () => ({
StaticLink: ({ children, href, ...props }: { children: React.ReactNode; href: string; [key: string]: unknown }) => (
<a href={href} {...props}>{children}</a>
),
}));
jest.mock('@/lib/utils', () => ({
cn: (...args: unknown[]) => args.filter(Boolean).join(' '),
}));
describe('MobileMenu', () => {
beforeEach(() => {
jest.clearAllMocks();
});
describe('Rendering', () => {
it('should render menu button', () => {
render(<MobileMenu />);
expect(screen.getByRole('button', { name: '打开菜单' })).toBeInTheDocument();
});
it('should render menu icon when closed', () => {
render(<MobileMenu />);
const button = screen.getByRole('button');
expect(button).toBeInTheDocument();
});
it('should not render menu panel when closed', () => {
render(<MobileMenu />);
expect(screen.queryByRole('navigation')).not.toBeInTheDocument();
});
});
describe('Opening Menu', () => {
it('should open menu when button clicked', () => {
render(<MobileMenu />);
const button = screen.getByRole('button', { name: '打开菜单' });
fireEvent.click(button);
expect(screen.getByRole('navigation')).toBeInTheDocument();
});
it('should change button label when open', () => {
render(<MobileMenu />);
const button = screen.getByRole('button', { name: '打开菜单' });
fireEvent.click(button);
expect(screen.getByRole('button', { name: '关闭菜单' })).toBeInTheDocument();
});
it('should render navigation items', () => {
render(<MobileMenu />);
const button = screen.getByRole('button', { name: '打开菜单' });
fireEvent.click(button);
expect(screen.getByText('产品')).toBeInTheDocument();
expect(screen.getByText('服务')).toBeInTheDocument();
});
});
describe('Closing Menu', () => {
it('should close menu when button clicked again', () => {
render(<MobileMenu />);
const button = screen.getByRole('button', { name: '打开菜单' });
fireEvent.click(button);
const closeButton = screen.getByRole('button', { name: '关闭菜单' });
fireEvent.click(closeButton);
expect(screen.queryByRole('navigation')).not.toBeInTheDocument();
});
it('should close menu when overlay clicked', () => {
render(<MobileMenu />);
const button = screen.getByRole('button', { name: '打开菜单' });
fireEvent.click(button);
const overlay = document.querySelector('.fixed.inset-0');
if (overlay) {
fireEvent.click(overlay);
}
expect(screen.queryByRole('navigation')).not.toBeInTheDocument();
});
});
describe('Keyboard Navigation', () => {
it('should open menu with button click', () => {
render(<MobileMenu />);
const button = screen.getByRole('button', { name: '打开菜单' });
fireEvent.click(button);
expect(screen.getByRole('navigation')).toBeInTheDocument();
});
it('should not double-toggle menu on Enter or Space keydown', () => {
render(<MobileMenu />);
const button = screen.getByRole('button', { name: '打开菜单' });
// Enter/Space 由原生 button 的 click 处理,keydown 不应再次 toggle
fireEvent.keyDown(button, { key: 'Enter' });
expect(screen.queryByRole('navigation')).not.toBeInTheDocument();
fireEvent.keyDown(button, { key: ' ' });
expect(screen.queryByRole('navigation')).not.toBeInTheDocument();
});
it('should close menu with Escape key', () => {
render(<MobileMenu />);
const button = screen.getByRole('button', { name: '打开菜单' });
fireEvent.click(button);
fireEvent.keyDown(button, { key: 'Escape' });
expect(screen.queryByRole('navigation')).not.toBeInTheDocument();
});
});
describe('Accessibility', () => {
it('should have aria-expanded attribute', () => {
render(<MobileMenu />);
const button = screen.getByRole('button');
expect(button).toHaveAttribute('aria-expanded', 'false');
});
it('should update aria-expanded when open', () => {
render(<MobileMenu />);
const button = screen.getByRole('button', { name: '打开菜单' });
fireEvent.click(button);
expect(button).toHaveAttribute('aria-expanded', 'true');
});
it('should have aria-controls attribute', () => {
render(<MobileMenu />);
const button = screen.getByRole('button');
expect(button).toHaveAttribute('aria-controls', 'mobile-menu-panel');
});
it('should have navigation role', () => {
render(<MobileMenu />);
const button = screen.getByRole('button', { name: '打开菜单' });
fireEvent.click(button);
const nav = screen.getByRole('navigation');
expect(nav).toHaveAttribute('aria-label', '移动端导航');
});
});
describe('Styling', () => {
it('should have responsive visibility', () => {
const { container } = render(<MobileMenu />);
const wrapper = container.firstChild as HTMLElement;
expect(wrapper).toHaveClass('lg:hidden');
});
it('should apply custom className', () => {
const { container } = render(<MobileMenu className="custom-class" />);
const wrapper = container.firstChild as HTMLElement;
expect(wrapper).toHaveClass('custom-class');
});
});
});
-129
View File
@@ -1,129 +0,0 @@
'use client';
import { useState, useEffect } from 'react';
import { Menu, X, ChevronDown } from 'lucide-react';
import { StaticLink } from '@/components/ui/static-link';
import { useSiteConfig } from '@/lib/site-config';
import { cn } from '@/lib/utils';
import { useFocusTrap } from '@/hooks/use-focus-trap';
interface MobileMenuProps {
className?: string;
}
export function MobileMenu({ className }: MobileMenuProps) {
const config = useSiteConfig();
const [isOpen, setIsOpen] = useState(false);
const [expandedDropdown, setExpandedDropdown] = useState<string | null>(null);
const focusTrapRef = useFocusTrap<HTMLDivElement>(isOpen);
useEffect(() => {
if (isOpen) {
document.body.style.overflow = 'hidden';
} else {
document.body.style.overflow = 'unset';
}
return () => {
document.body.style.overflow = 'unset';
};
}, [isOpen]);
const handleKeyDown = (event: React.KeyboardEvent) => {
// Escape 关闭菜单;Enter/Space 已由原生 button 的 onClick 处理,
// 此处不再拦截,避免键盘操作时重复触发 toggle。
if (event.key === 'Escape' && isOpen) {
event.preventDefault();
setIsOpen(false);
}
};
const toggleDropdown = (key: string) => {
setExpandedDropdown(expandedDropdown === key ? null : key);
};
return (
<div className={cn('lg:hidden', className)} ref={focusTrapRef}>
<button
onClick={() => setIsOpen(!isOpen)}
onKeyDown={handleKeyDown}
className="p-3 rounded-md hover:bg-[var(--color-brand-bg)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--color-brand)] focus:ring-offset-2 min-w-[48px] min-h-[48px] flex items-center justify-center"
aria-label={isOpen ? '关闭菜单' : '打开菜单'}
aria-expanded={isOpen}
aria-controls="mobile-menu-panel"
>
{isOpen ? (
<X className="w-6 h-6 text-[var(--color-text-primary)]" />
) : (
<Menu className="w-6 h-6 text-[var(--color-text-primary)]" />
)}
</button>
{isOpen && (
<>
<div
className="fixed inset-0 bg-[var(--color-brand)]/20 backdrop-blur-sm z-40"
onClick={() => setIsOpen(false)}
aria-hidden="true"
/>
<nav
id="mobile-menu-panel"
className="fixed top-16 left-0 right-0 bg-[var(--color-bg-primary)] border-b border-[var(--color-border-primary)] z-50 shadow-lg max-h-[calc(100vh-4rem)] overflow-y-auto"
role="navigation"
aria-label="移动端导航"
>
<div className="container-wide py-4">
<ul className="space-y-1" role="list">
{config.mainNav.map((item) => (
<li key={item.id}>
{item.hasDropdown && item.dropdownKey ? (
<div>
<button
onClick={() => toggleDropdown(item.dropdownKey!)}
className="flex items-center justify-between w-full text-left px-4 py-4 text-[var(--color-text-primary)] hover:bg-[var(--color-brand-bg)] hover:text-[var(--color-brand)] rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--color-brand)] focus:ring-inset min-h-[48px]"
aria-expanded={expandedDropdown === item.dropdownKey}
>
{item.label}
<ChevronDown
className={cn(
'w-4 h-4 transition-transform duration-200',
expandedDropdown === item.dropdownKey && 'rotate-180'
)}
/>
</button>
{expandedDropdown === item.dropdownKey && (
<ul className="pl-4 space-y-1 mt-1 mb-2" role="list">
{(config.megaDropdown[item.dropdownKey] ?? []).flatMap(group => group.items).filter(sub => sub.href !== '#').map((sub) => (
<li key={sub.id}>
<StaticLink
href={sub.href}
onClick={() => setIsOpen(false)}
className="block px-4 py-3 text-sm text-[var(--color-text-muted)] hover:text-[var(--color-brand)] hover:bg-[var(--color-brand-bg)] rounded-md transition-colors"
>
<span className="font-medium text-[var(--color-text-primary)]">{sub.title}</span>
<span className="block text-xs text-[var(--color-text-muted)] mt-0.5">{sub.description}</span>
</StaticLink>
</li>
))}
</ul>
)}
</div>
) : (
<StaticLink
href={item.href}
onClick={() => setIsOpen(false)}
className="block px-4 py-4 text-[var(--color-text-primary)] hover:bg-[var(--color-brand-bg)] hover:text-[var(--color-brand)] rounded-md transition-colors min-h-[48px]"
>
{item.label}
</StaticLink>
)}
</li>
))}
</ul>
</div>
</nav>
</>
)}
</div>
);
}
@@ -41,7 +41,7 @@ describe('MobileTabBar', () => {
expect(screen.getByText('首页')).toBeInTheDocument();
expect(screen.getByText('产品')).toBeInTheDocument();
expect(screen.getByText('方案')).toBeInTheDocument();
expect(screen.getByText('关于')).toBeInTheDocument();
expect(screen.getByText('案例')).toBeInTheDocument();
expect(screen.getByText('联系')).toBeInTheDocument();
});
@@ -86,10 +86,10 @@ describe('MobileTabBar', () => {
expect(productsLink).toHaveAttribute('href', '/products');
});
it('should have correct href for about', () => {
it('should have correct href for cases', () => {
render(<MobileTabBar />);
const aboutLink = screen.getByText('关于').closest('a');
expect(aboutLink).toHaveAttribute('href', '/about');
const casesLink = screen.getByText('案例').closest('a');
expect(casesLink).toHaveAttribute('href', '/cases');
});
it('should have correct href for contact', () => {
+10 -13
View File
@@ -2,15 +2,17 @@
import { StaticLink } from '@/components/ui/static-link';
import { usePathname } from 'next/navigation';
import { Home, Lightbulb, Package, FileText, User } from 'lucide-react';
import { Home, Lightbulb, Package, FolderOpen, User } from 'lucide-react';
import { motion } from 'framer-motion';
import { cn } from '@/lib/utils';
// 关于页让位给案例页:转化路径上「看实证」优先于「看介绍」,
// 关于/新闻等仍可通过汉堡抽屉(header)到达。
const tabs = [
{ id: 'home', label: '首页', href: '/', icon: Home },
{ id: 'products', label: '产品', href: '/products', icon: Package },
{ id: 'solutions', label: '方案', href: '/solutions', icon: Lightbulb },
{ id: 'about', label: '关于', href: '/about', icon: FileText },
{ id: 'cases', label: '案例', href: '/cases', icon: FolderOpen },
{ id: 'contact', label: '联系', href: '/contact', icon: User },
];
@@ -30,8 +32,8 @@ export function MobileTabBar() {
if (id === 'solutions') {
return pathname === '/solutions' || pathname.startsWith('/solutions/');
}
if (id === 'about') {
return pathname === '/about';
if (id === 'cases') {
return pathname === '/cases' || pathname.startsWith('/cases/');
}
return false;
};
@@ -50,13 +52,6 @@ export function MobileTabBar() {
className="flex flex-col items-center justify-center flex-1 h-full relative group min-h-12"
>
<div className="relative flex flex-col items-center justify-center py-2">
{active && (
<motion.div
layoutId="activeTabTop"
className="absolute -top-0 w-6 h-[3px] bg-brand"
transition={{ type: 'spring', stiffness: 380, damping: 30 }}
/>
)}
<Icon
className={cn(
'w-6 h-6 transition-colors duration-300',
@@ -72,10 +67,12 @@ export function MobileTabBar() {
{tab.label}
</span>
{active && (
/* critique P2(2026-09-19):双下划线为同状态冗余编码,只保留 tab 惯例的
底部指示条;spring 违反「内容入场禁回弹」,改 ease-ink 200ms。 */
<motion.div
layoutId="activeTabBottom"
layoutId="activeTab"
className="absolute -bottom-1 w-8 h-0.5 bg-brand"
transition={{ type: 'spring', stiffness: 380, damping: 30 }}
transition={{ duration: 0.2, ease: [0.22, 1, 0.36, 1] }}
/>
)}
</div>