refactor(deadcode): 删 17 个不可达模块并做成可复跑的可达性判定,棘轮回到绿且未降任何门限

台账 DEC-P-2 的死码族一直靠人工 grep 猜,本轮做成 scripts/dead-modules.mjs:
从真实入口(app/**/page|layout|route + Next 约定文件)做 import 闭包,再分类。
**这台仪器本身修了三次才可信,每一次都是"看似合理但会误删活码"**:
1. 只匹配 `from '...'` ⇒ `dynamic(() => import('./GoogleAnalytics'))` 这条边不存在,
   GA 组件被报成"零引用死码"。照那结果删,GA4 会在没有任何渲染断言的情况下从页面消失。
2. 只扫 src/ ⇒ scripts/utils/check-color-contrast.ts import 的 src/lib/color-contrast.ts
   被报成死码(门禁自己的依赖不在图内)。
3. 入口正则写成 /app\/.*(^|\/)layout\.tsx$/ ⇒ 强制 layout.tsx 前有 '/',
   于是 **src/app/layout.tsx 这种根级约定文件根本不算入口**,它 import 的整棵树
   全部误判死码(实测把 home-content-v16、layout 自己都报成死码,129 个假死码)。
4. 相对导入用 path.resolve 解析成绝对路径,而模块表 key 是相对路径 ⇒ 所有 `./x` 边静默丢弃,
   可达数看着像个数其实半瞎。
归一后:入口 65 · 站内模块 489 · 可达 295 · 不可达 194 —— 其中
convention 4 / generated 2 / **library 53(组件库库存,删除是产品决定,本轮不删)** /
test 118 / **dead 仅 17**。前几版报的 48~129 个"死码"绝大多数是假阳性。

删除 17 个(含 5 个专属测试 + 3 个 describe 块 + 1 段孤儿 jest.mock):
sections 下 11 个被页面自己手写实现取代的区块、两个 breadcrumb、NewsDetailClient
(news 详情页实际用的是 news-detail-content-v3)、lib/cms/index.ts 空桶、
design-system.ts。删后 dead-modules 复判 0。

**棘轮被打破,而我拒绝用"降门限"来让它闭嘴**(这是本轮最重要的一个决定):
删完 `npm run test:coverage` EXIT=1,./src/lib/ functions 84.95(门限85)、
./src/lib/constants/ functions 51.51(门限55)。先做了归因 —— 用真闸而不是自拼 config
(我第一版自拼 config 测的"基线"是坏测量:漏跑 prisma generate ⇒ 套件全崩 ⇒ 0% 覆盖率)。
结论:da9a5cb6 上这道闸 EXIT=0 通过,是我打破的;且 design-system.ts 有 100% 覆盖的函数,
**删掉一个"有完整测试的死码"在数学上必然拉低目录均值** —— 门限此前是被"永远不会上线的代码
的测试"撑着的。
处置:一处门限都没改。改为
- 补真测试:getHeroTheme 未知 id 回落 default、交叉引用兜底、常量桶一致性守卫
- 删掉我在 nav-active.ts 里写出的一条**不可达分支**(函数开头已 `if(!href) return false`,
  `target===''` 永不可达;留着它会让覆盖率报告出现"没覆盖到的分支",诱导出一个假测试)
- 修掉一个既有潜伏陷阱:根桶 constants.ts 与子桶 constants/index.ts **两条平行出口不一致**,
  根桶漏了 getHeroTheme / 三个 CrossRefs / commitments / cta-labels / metrics-basis 全部符号
  ⇒ `import { getHeroTheme } from '@/lib/constants'` 会拿到 undefined,调用时才炸、
  静态检查不拦。补齐后 All files functions 82.28 → **87.62**,COVERAGE_EXIT=0。
这条漂移是刚写的桶守卫当场抓出来的(它先以"函数是 undefined"判红),不是我事后编的测试。

门禁实测:type-check EXIT=0 · 全量 jest 通过 · test:coverage EXIT=0(未动任何阈值)·
check:grammar 9/9 与 selftest 9/9 · token-twins · contrast · brand-token 全 EXIT=0
This commit is contained in:
zhangxiang committed 2026-10-17 00:17:40 +08:00
1 parent d9f9ee77cf
commit ffc43fdeb7
32 files changed
+298 -3184

No files matched your search

-43
View File
@@ -168,49 +168,6 @@ jest.mock('lucide-react', () => {
return icons;
});
jest.mock('@/lib/constants/design-system', () => ({
DESIGN_SYSTEM: {
animation: {
duration: { fast: '0.2s', normal: '0.4s', slow: '0.6s', slower: '0.8s', countUp: '2s' },
easing: { smooth: 'cubic-bezier(0.4, 0, 0.2, 1)', bounce: 'cubic-bezier(0.34, 1.56, 0.64, 1)', easeOut: 'cubic-bezier(0, 0, 0.2, 1)', easeInOut: 'cubic-bezier(0.4, 0, 0.6, 1)' },
delay: { stagger: 0.08, section: 0.15 },
},
spacing: {
section: { py: 'py-20 lg:py-28', pyCompact: 'py-16 lg:py-20' },
container: { default: 'max-w-7xl mx-auto px-4 sm:px-6 lg:px-8', narrow: 'max-w-5xl mx-auto px-4 sm:px-6 lg:px-8', wide: 'max-w-[1400px] mx-auto px-4 sm:px-6 lg:px-8' },
grid: { gap: 'gap-6 lg:gap-8', gapSmall: 'gap-4 lg:gap-6' },
},
typography: {
hero: { title: 'text-4xl', subtitle: 'text-lg', description: 'text-base' },
section: { title: 'text-3xl', subtitle: 'text-lg', body: 'text-base' },
card: { title: 'text-lg', description: 'text-sm' },
},
effects: {
inkGlow: { border: 'conic-gradient(...)', glow: 'radial-gradient(...)', speed: '3s' },
hover: { translateY: '-4px', shadow: 'shadow-xl', transition: 'all 0.3s' },
scroll: {
fadeInUp: {
initial: { opacity: 0, y: 24 },
animate: { opacity: 1, y: 0 },
viewport: { once: true, margin: '-80px' },
transition: { duration: 0.6, ease: [0.16, 1, 0.3, 1] },
},
staggerChildren: { delay: 0.08 },
},
},
colors: {
brand: { primary: 'var(--color-brand)', light: 'var(--color-brand-bg)', lighter: 'rgba(var(--color-brand-rgb), 0.04)', gradient: 'linear-gradient(135deg, var(--color-brand) 0%, #99182d 100%)' },
neutral: { '50': 'var(--color-bg-primary)', '100': 'var(--color-bg-section)', '200': 'var(--color-border-primary)' },
ink: { light: 'rgba(0, 0, 0, 0.03)', medium: 'rgba(0, 0, 0, 0.06)' },
},
components: {
card: { base: 'rounded-2xl', hover: 'hover:-translate-y-1', padding: 'p-6' },
badge: { base: 'inline-flex', variants: { primary: 'bg-brand-soft', secondary: 'bg-bg-tertiary' } },
button: { primary: 'bg-brand', secondary: 'bg-white', ghost: 'bg-transparent' },
metric: { container: 'text-center', value: 'text-3xl', label: 'text-sm', description: 'text-xs' },
},
},
}));
// ─── Mock Data ───────────────────────────────────────────────────────────
-52
View File
@@ -1,52 +0,0 @@
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import { Breadcrumb } from './breadcrumb';
jest.mock('next/link', () => {
return ({ children, href }: { children: React.ReactNode; href: string }) => {
return <a href={href}>{children}</a>;
};
});
describe('Breadcrumb', () => {
beforeEach(() => {
jest.clearAllMocks();
});
describe('Rendering', () => {
it('should render breadcrumb component', () => {
render(<Breadcrumb items={[]} />);
const nav = screen.getByRole('navigation', { name: /breadcrumb/i });
expect(nav).toBeInTheDocument();
});
it('should render home link', () => {
render(<Breadcrumb items={[]} />);
const homeLinks = screen.getAllByRole('link');
expect(homeLinks.length).toBeGreaterThan(0);
});
it('should render breadcrumb items', () => {
const items = [
{ label: 'Products', href: '/products' },
{ label: 'Details', href: '/products/1' },
];
render(<Breadcrumb items={items} />);
const productLink = screen.getByRole('link', { name: /Products/i });
const detailsLink = screen.getByRole('link', { name: /Details/i });
expect(productLink).toBeInTheDocument();
expect(detailsLink).toBeInTheDocument();
});
});
describe('Accessibility', () => {
it('should have nav element with aria-label', () => {
render(<Breadcrumb items={[]} />);
const nav = screen.getByRole('navigation', { name: /breadcrumb/i });
expect(nav).toBeInTheDocument();
});
});
});
-38
View File
@@ -1,38 +0,0 @@
'use client';
import { StaticLink } from '@/components/ui/static-link';
import { ChevronRight, Home } from 'lucide-react';
interface BreadcrumbItem {
label: string;
href: string;
}
interface BreadcrumbProps {
items: BreadcrumbItem[];
}
export function Breadcrumb({ items }: BreadcrumbProps) {
return (
<nav aria-label="breadcrumb" className="flex items-center space-x-1 text-sm text-text-muted py-4">
<StaticLink
href="/"
className="flex items-center hover:text-text-primary transition-colors duration-fast"
aria-label="返回首页"
>
<Home className="w-3.5 h-3.5" />
</StaticLink>
{items.map((item, index) => (
<div key={index} className="flex items-center">
<ChevronRight className="w-3.5 h-3.5 text-border-secondary" />
<StaticLink
href={item.href}
className="ml-1 hover:text-text-primary transition-colors duration-fast"
>
{item.label}
</StaticLink>
</div>
))}
</nav>
);
}
-123
View File
@@ -1,123 +0,0 @@
// @ts-nocheck
import { describe, it, expect, jest } from '@jest/globals';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
// ─── Mocks ───────────────────────────────────────────────────────────────
jest.mock('framer-motion', () => ({
motion: {
div: ({ children, initial, animate, variants, whileInView, whileHover, whileTap, viewport, transition, className, ...props }: any) => (
<div
data-testid="motion-div"
data-initial={JSON.stringify(initial)}
data-animate={JSON.stringify(animate)}
data-variants={JSON.stringify(variants)}
data-while-hover={JSON.stringify(whileHover)}
data-while-tap={JSON.stringify(whileTap)}
data-while-inview={JSON.stringify(whileInView)}
data-viewport={JSON.stringify(viewport)}
data-transition={JSON.stringify(transition)}
className={className}
{...props}
>
{children}
</div>
),
},
useInView: jest.fn(() => true),
AnimatePresence: ({ children }: any) => <>{children}</>,
}));
// ─── Mock Data ────────────────────────────────────────────────────────────
const mockCase = {
industry: '制造业',
title: '某制造企业数字化转型',
challenge: '库存管理混乱,信息孤岛严重,生产流程不透明',
solution: '实施ERP系统,打通全业务流程,实现数据驱动决策',
impact: [
{ value: '200%', label: '库存周转率提升' },
{ value: '50%', label: '运营成本降低' },
],
quote: '数字化转型让我们的生产效率大幅提升',
author: '张总 / 某制造企业CEO',
image: '/images/cases/manufacturing.jpg',
};
// ─── Tests ───────────────────────────────────────────────────────────────
describe('CaseCard', () => {
it('should render industry tag and title', async () => {
const { CaseCard } = await import('./case-card');
render(<CaseCard {...mockCase} />);
expect(screen.getByText('制造业')).toBeInTheDocument();
expect(screen.getByText('某制造企业数字化转型')).toBeInTheDocument();
});
it('should render challenge and solution', async () => {
const { CaseCard } = await import('./case-card');
render(<CaseCard {...mockCase} />);
expect(screen.getByText('挑战')).toBeInTheDocument();
expect(screen.getByText('方案')).toBeInTheDocument();
expect(screen.getByText('库存管理混乱,信息孤岛严重,生产流程不透明')).toBeInTheDocument();
expect(screen.getByText('实施ERP系统,打通全业务流程,实现数据驱动决策')).toBeInTheDocument();
});
it('should render impact metrics', async () => {
const { CaseCard } = await import('./case-card');
render(<CaseCard {...mockCase} />);
expect(screen.getByText('200%')).toBeInTheDocument();
expect(screen.getByText('库存周转率提升')).toBeInTheDocument();
expect(screen.getByText('50%')).toBeInTheDocument();
expect(screen.getByText('运营成本降低')).toBeInTheDocument();
});
it('should render quote and author', async () => {
const { CaseCard } = await import('./case-card');
render(<CaseCard {...mockCase} />);
expect(screen.getByText(/数字化转型让我们的生产效率大幅提升/)).toBeInTheDocument();
expect(screen.getByText('张总 / 某制造企业CEO')).toBeInTheDocument();
});
it('should render background image when provided', async () => {
const { CaseCard } = await import('./case-card');
const { container } = render(<CaseCard {...mockCase} />);
// 组件用 CSS 背景图而非 <img>,使 404 图片静默降级为纯色底
const bg = container.querySelector('[style*="background-image"]');
expect(bg).toBeInTheDocument();
expect(bg).toHaveAttribute('aria-hidden', 'true');
expect(bg).toHaveStyle({ backgroundImage: 'url(/images/cases/manufacturing.jpg)' });
});
it('should not render background image when not provided', async () => {
const { CaseCard } = await import('./case-card');
const { container } = render(<CaseCard {...mockCase} image={undefined} />);
const bg = container.querySelector('[style*="background-image"]');
expect(bg).not.toBeInTheDocument();
});
it('should use context as fallback when challenge is empty', async () => {
const { CaseCard } = await import('./case-card');
render(
<CaseCard
industry="测试"
title="Test"
challenge=""
solution=""
context="后备上下文"
impact={mockCase.impact}
quote="quote"
author="author"
/>
);
expect(screen.getByText('后备上下文')).toBeInTheDocument();
});
it('should apply custom className', async () => {
const { CaseCard } = await import('./case-card');
const { container } = render(<CaseCard {...mockCase} className="custom-class" />);
const outer = container.querySelector('.custom-class');
expect(outer).toBeInTheDocument();
});
});
-127
View File
@@ -1,127 +0,0 @@
'use client';
interface CaseImpact {
value: string;
label: string;
}
interface CaseCardProps {
/** Industry label (e.g. "制造业") */
industry: string;
/** Case title */
title: string;
/** Challenge the client faced (Bain-style) */
challenge: string;
/** Solution we provided (Bain-style) */
solution: string;
/** @deprecated Use challenge + solution instead */
context?: string;
/** Quantified impact metrics (2 items) */
impact: CaseImpact[];
/** Client quote */
quote: string;
/** Client name/title */
author: string;
/** Optional background image URL */
image?: string;
className?: string;
}
export function CaseCard({
industry,
title,
challenge,
solution,
context,
impact,
quote,
author,
image,
className = '',
}: CaseCardProps) {
const displayChallenge = challenge || context || '';
const displaySolution = solution || '';
return (
<div
className={`group relative overflow-hidden p-6 sm:p-8 md:p-10 lg:p-14 flex flex-col transition-all duration-150 bg-[var(--color-bg-primary)] border border-[var(--color-border-primary)] hover:bg-[var(--color-bg-secondary)] ${className}`}
>
{/* Background image */}
{image && (
<div
aria-hidden="true"
style={{ backgroundImage: `url(${image})` }}
className="absolute inset-0 bg-cover bg-center transition-opacity duration-150 opacity-[0.02] group-hover:opacity-[0.05]"
/>
)}
<div className="relative z-10 flex flex-col flex-1">
{/* Industry tag */}
<div
className="text-[10px] tracking-[3px] uppercase font-medium mb-4 md:mb-5"
style={{ color: 'var(--color-text-muted)' }}
>
{industry}
</div>
{/* Title */}
<h3 className="font-sans text-[19px] sm:text-[22px] font-bold leading-[1.3] tracking-[-0.3px] text-[var(--color-text-primary)] mb-5 md:mb-6">
{title}
</h3>
{/* Bain-style: Challenge + Solution */}
<div className="space-y-4 mb-6 md:mb-8 flex-1">
{/* Challenge */}
<div>
<div
className="text-[10px] tracking-[2px] uppercase font-semibold mb-2"
style={{ color: 'var(--color-brand)' }}
>
挑战
</div>
<p className="text-[13px] sm:text-[14px] leading-relaxed text-[var(--color-text-secondary)]">
{displayChallenge}
</p>
</div>
{/* Solution (only if provided) */}
{displaySolution && (
<div>
<div
className="text-[10px] tracking-[2px] uppercase font-semibold mb-2"
style={{ color: 'var(--color-brand)' }}
>
方案
</div>
<p className="text-[13px] sm:text-[14px] leading-relaxed text-[var(--color-text-secondary)]">
{displaySolution}
</p>
</div>
)}
</div>
{/* Impact numbers — Results (Bain-style, most visual weight) */}
<div className="grid grid-cols-2 gap-4 sm:gap-6 pt-5 md:pt-7 mb-5 md:mb-7 border-t border-[var(--color-border-primary)]">
{impact.map((item, i) => (
<div key={i} className="transition-transform duration-normal group-hover:scale-[1.02]">
<div className="font-sans tabular-nums text-[32px] sm:text-[38px] md:text-[42px] font-bold leading-none mb-1 md:mb-1.5 tracking-[-1.5px] text-[var(--color-text-primary)]">
{item.value}
</div>
<div className="text-[10px] sm:text-[11px] text-[var(--color-text-muted)]">
{item.label}
</div>
</div>
))}
</div>
{/* Quote */}
<blockquote className="text-[13px] leading-relaxed italic mb-2 md:mb-3 text-[var(--color-text-secondary)]">
&ldquo;{quote}&rdquo;
</blockquote>
<cite className="text-[11px] sm:text-[12px] not-italic text-[var(--color-text-muted)]">
{author}
</cite>
</div>
</div>
);
}
@@ -1,74 +0,0 @@
'use client';
import { motion } from 'framer-motion';
import { ChallengeCard } from '@/components/ui/challenge-card';
import { GeometricDecoration } from '@/components/ui/brand-visuals';
import { useReducedMotion } from '@/hooks/use-reduced-motion';
const CHALLENGES = [
{
id: 'data-isolation',
title: '数据孤岛',
description: '各部门系统独立运行,数据无法互通共享,导致决策信息碎片化,影响整体运营效率。',
scenario: 'isolation' as const,
href: '/solutions#consulting',
},
{
id: 'growth-bottleneck',
title: '增长瓶颈',
description: '业务规模扩大但管理手段滞后,流程效率低下,难以支撑持续增长的业务需求。',
scenario: 'growth' as const,
href: '/solutions#tech',
},
{
id: 'compliance-risk',
title: '合规风险',
description: '行业监管日趋严格,传统手工操作难以满足合规要求,数据安全和审计面临挑战。',
scenario: 'compliance' as const,
href: '/solutions#accompany',
},
];
export function ChallengeSection() {
const shouldReduceMotion = useReducedMotion();
return (
<section id="challenges" className="relative py-20 md:py-28 bg-[var(--color-bg-section)] bg-gradient-subtle-warm">
<GeometricDecoration variant="circles" />
<div className="container-wide">
<motion.div
initial={shouldReduceMotion ? {} : { opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true, margin: '-100px' }}
transition={{ duration: 0.28, ease: [0.16, 1, 0.3, 1] }}
className="mb-14"
>
<div className="flex items-center gap-4 mb-4">
<div className="h-px flex-1 bg-[var(--color-border-primary)]" />
<span className="text-xs font-mono tracking-widest text-[var(--color-text-subtle)]">CHALLENGES</span>
<div className="h-px flex-1 bg-[var(--color-border-primary)]" />
</div>
<h2 className="text-3xl sm:text-4xl font-semibold text-[var(--color-text-primary)] text-center">
您的挑战,我们的<span className="text-brand-ink font-calligraphy">使命</span>
</h2>
<p className="text-base text-[var(--color-text-muted)] text-center mt-4 max-w-xl mx-auto">
深入理解企业数字化进程中的核心痛点,提供针对性解决方案
</p>
</motion.div>
<div className="grid grid-cols-1 md:grid-cols-3 gap-6 md:gap-8">
{CHALLENGES.map((challenge, index) => (
<ChallengeCard
key={challenge.id}
title={challenge.title}
description={challenge.description}
scenario={challenge.scenario}
href={challenge.href}
index={index}
/>
))}
</div>
</div>
</section>
);
}
-105
View File
@@ -1,105 +0,0 @@
'use client';
import { useRef } from 'react';
import { motion } from 'framer-motion';
import { StaticLink } from '@/components/ui/static-link';
import { CTA_LABELS } from '@/lib/constants/cta-labels';
import { Button } from '@/components/ui/button';
import { BrandStamp } from '@/components/ui/brand-visuals';
import { ArrowRight, Sparkles, MessageCircle, Clock, ShieldCheck } from 'lucide-react';
import { useReducedMotion } from '@/hooks/use-reduced-motion';
interface CTASectionProps {
title?: string;
description?: string;
primaryLabel?: string;
primaryHref?: string;
secondaryLabel?: string;
secondaryHref?: string;
}
export function CTASection({
title = '一起聊聊您的数字化需求',
description = `无论您处于数字化转型的哪个阶段,我们都愿意坐下来一起想办法。首次咨询免费,无任何销售压力。`,
primaryLabel = CTA_LABELS.consult,
primaryHref = '/contact',
secondaryLabel = '了解我们的方法',
secondaryHref = '/team',
}: CTASectionProps) {
const shouldReduceMotion = useReducedMotion();
const containerRef = useRef<HTMLDivElement>(null);
return (
<section
id="cta"
ref={containerRef}
className="relative py-24 md:py-32 overflow-hidden"
style={{ backgroundColor: 'var(--color-bg-secondary)' }}
>
<div className="container-wide relative z-10">
<motion.div
initial={shouldReduceMotion ? {} : { opacity: 0, scale: 0.96, y: 16 }}
whileInView={{ opacity: 1, scale: 1, y: 0 }}
viewport={{ once: true, margin: '-80px' }}
transition={{ duration: 0.28, ease: [0.16, 1, 0.3, 1] }}
className="text-center max-w-3xl mx-auto relative"
>
<div className="absolute -top-8 left-1/2 -translate-x-1/2 hidden md:block">
<BrandStamp>值得信赖</BrandStamp>
</div>
<motion.div
initial={shouldReduceMotion ? {} : { opacity: 0, y: -8 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ duration: 0.28, delay: 0.15 }}
className="inline-flex items-center gap-2 px-4 py-1.5 rounded-full bg-[var(--color-brand-soft)] border border-[var(--color-border-primary)] mb-8"
>
<Sparkles className="w-3.5 h-3.5 text-brand-ink" />
<span className="text-sm font-medium text-[var(--color-text-primary)]">开始对话</span>
</motion.div>
<h2 className="text-4xl sm:text-5xl lg:text-6xl font-semibold text-[var(--color-text-primary)] mb-6 tracking-tight leading-tight">
{title}
</h2>
<p className="text-lg md:text-xl text-[var(--color-text-secondary)] leading-relaxed mb-10 max-w-2xl mx-auto">
{description}
</p>
<div className="flex flex-wrap items-center justify-center gap-3 mb-10">
<div className="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-[var(--color-bg-primary)] border border-[var(--color-border-primary)] text-[var(--color-text-secondary)] text-xs">
<MessageCircle className="w-3.5 h-3.5" />
<span>免费咨询</span>
</div>
<div className="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-[var(--color-bg-primary)] border border-[var(--color-border-primary)] text-[var(--color-text-secondary)] text-xs">
<Clock className="w-3.5 h-3.5" />
<span>30 分钟内响应</span>
</div>
<div className="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-[var(--color-bg-primary)] border border-[var(--color-border-primary)] text-[var(--color-text-secondary)] text-xs">
<ShieldCheck className="w-3.5 h-3.5" />
<span>无销售压力</span>
</div>
</div>
<div className="flex flex-col sm:flex-row items-center justify-center gap-4">
<Button size="lg" asChild className="group relative overflow-hidden">
<StaticLink href={primaryHref}>
<span className="relative z-10 flex items-center">
<MessageCircle className="w-4 h-4 mr-2" />
{primaryLabel}
<ArrowRight className="w-4 h-4 ml-2 group-hover:translate-x-1 transition-transform" />
</span>
</StaticLink>
</Button>
<Button
size="lg"
variant="outline"
asChild
>
<StaticLink href={secondaryHref}>{secondaryLabel}</StaticLink>
</Button>
</div>
</motion.div>
</div>
</section>
);
}
@@ -1,507 +0,0 @@
import { describe, it, expect, jest, beforeEach, afterEach } from '@jest/globals';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import HeroParticleField, { type HeroVariant } from './hero-particle-field';
// ─── Mocks ───────────────────────────────────────────────────────────────
// 本文件负责粒子引擎(绘制分支 / 出界回绕 / 启停),不做快照比对,
// 因此把 canvas 2d 上下文换成可回放的记录器:jsdom 无 canvas 实现,
// 不打桩的话 useEffect 会在 getContext('2d') 处提前 return(见 hero-particle-field.tsx:107)。
jest.mock('@/hooks/use-reduced-motion', () => ({
useReducedMotion: jest.fn(() => false),
}));
type Call = { op: string; args: unknown[] };
type StyleWrite = { prop: string; value: string };
interface CtxStub {
calls: Call[];
styles: StyleWrite[];
gradients: { addColorStop: jest.Mock }[];
}
function createCtxStub() {
const calls: Call[] = [];
const styles: StyleWrite[] = [];
const gradients: { addColorStop: jest.Mock }[] = [];
const record = (op: string) =>
jest.fn((...args: unknown[]) => {
calls.push({ op, args });
});
const stub: Record<string, unknown> = {
calls,
styles,
gradients,
setTransform: record('setTransform'),
clearRect: record('clearRect'),
beginPath: record('beginPath'),
moveTo: record('moveTo'),
lineTo: record('lineTo'),
stroke: record('stroke'),
arc: record('arc'),
fill: record('fill'),
createLinearGradient: jest.fn(() => {
const g = { addColorStop: jest.fn() };
gradients.push(g);
return g;
}),
};
for (const prop of ['lineWidth', 'globalAlpha', 'shadowColor', 'shadowBlur', 'strokeStyle', 'fillStyle']) {
let value: unknown = '';
Object.defineProperty(stub, prop, {
configurable: true,
get: () => value,
set: (next: unknown) => {
value = next;
styles.push({ prop, value: String(next) });
},
});
}
return stub as unknown as CanvasRenderingContext2D & CtxStub;
}
// ─── 环境夹具 ────────────────────────────────────────────────────────────
const VIEWPORT = { width: 1200, height: 700 };
const originalWebdriver = navigator.webdriver;
let ctxStub: CanvasRenderingContext2D & CtxStub;
let getCtxSpy: jest.SpiedFunction<typeof HTMLCanvasElement.prototype.getContext>;
let rectSpy: jest.SpiedFunction<typeof Element.prototype.getBoundingClientRect>;
let frameQueue: Array<(t: number) => void>;
let rafSpy: jest.SpiedFunction<typeof window.requestAnimationFrame>;
let cafSpy: jest.SpiedFunction<typeof window.cancelAnimationFrame>;
/** jsdom 里 navigator.webdriver 默认为 true → 引擎走静态降级;本夹具默认要的是可动画环境 */
function setWebdriver(value: boolean) {
Object.defineProperty(navigator, 'webdriver', { configurable: true, get: () => value });
}
function setReduceMotion(value: boolean) {
const { useReducedMotion } = require('@/hooks/use-reduced-motion');
(useReducedMotion as jest.Mock).mockReturnValue(value);
}
function setViewport(size: { width: number; height: number }) {
rectSpy.mockReturnValue({
...size,
top: 0,
left: 0,
right: size.width,
bottom: size.height,
x: 0,
y: 0,
toJSON: () => ({}),
} as DOMRect);
}
/** 画布「可见尺寸」决定回绕边界,与 build() 用的父容器矩形分离,便于构造出界场景 */
function setCanvasClientBox(width: number, height: number) {
Object.defineProperty(HTMLCanvasElement.prototype, 'clientWidth', { configurable: true, get: () => width });
Object.defineProperty(HTMLCanvasElement.prototype, 'clientHeight', { configurable: true, get: () => height });
}
function arcPositions(since = 0): { x: number; y: number }[] {
return ctxStub.calls
.slice(since)
.filter((c) => c.op === 'arc')
.map((c) => ({ x: Number(c.args[0]), y: Number(c.args[1]) }));
}
function written(prop: string): string[] {
return ctxStub.styles.filter((s) => s.prop === prop).map((s) => s.value);
}
/** 手动推进 rAF 队列,返回推进的帧数 */
function runFrames(stamps: number[]): number {
let done = 0;
for (const t of stamps) {
const pending = frameQueue.splice(0, frameQueue.length);
if (pending.length === 0) break;
pending.forEach((cb) => cb(t));
done += 1;
}
return done;
}
/** 动画路径下 build() 不直接落笔(paint 只发生在 step 内),推进一帧即可检查绘制结果 */
function paintOnce() {
expect(runFrames([16])).toBe(1);
}
beforeEach(() => {
ctxStub = createCtxStub();
frameQueue = [];
getCtxSpy = jest
.spyOn(HTMLCanvasElement.prototype, 'getContext')
.mockImplementation((() => ctxStub) as never);
rectSpy = jest.spyOn(Element.prototype, 'getBoundingClientRect').mockReturnValue({
...VIEWPORT,
top: 0,
left: 0,
right: VIEWPORT.width,
bottom: VIEWPORT.height,
x: 0,
y: 0,
toJSON: () => ({}),
} as DOMRect);
rafSpy = jest
.spyOn(window, 'requestAnimationFrame')
.mockImplementation(((cb: (t: number) => void) => {
frameQueue.push(cb);
return frameQueue.length;
}) as never);
cafSpy = jest.spyOn(window, 'cancelAnimationFrame').mockImplementation((() => undefined) as never);
setWebdriver(false);
setReduceMotion(false);
setCanvasClientBox(VIEWPORT.width, VIEWPORT.height);
document.documentElement.style.removeProperty('--color-brand-rgb');
});
afterEach(() => {
getCtxSpy.mockRestore();
rectSpy.mockRestore();
rafSpy.mockRestore();
cafSpy.mockRestore();
setWebdriver(originalWebdriver);
Object.defineProperty(HTMLCanvasElement.prototype, 'clientWidth', { configurable: true, get: () => 0 });
Object.defineProperty(HTMLCanvasElement.prototype, 'clientHeight', { configurable: true, get: () => 0 });
document.documentElement.style.removeProperty('--color-brand-rgb');
delete (globalThis as Record<string, unknown>).ResizeObserver;
});
// ─── 尺寸与密度 ──────────────────────────────────────────────────────────
describe('HeroParticleField · 画布尺寸与粒子密度', () => {
it('sizes the backing store by devicePixelRatio and caps DPR at 2', () => {
Object.defineProperty(window, 'devicePixelRatio', { configurable: true, get: () => 4 });
const { unmount } = render(<HeroParticleField />);
const canvas = screen.getByTestId('hero-particle-field') as HTMLCanvasElement;
expect(canvas.width).toBe(VIEWPORT.width * 2);
expect(canvas.height).toBe(VIEWPORT.height * 2);
expect(canvas.style.width).toBe('1200px');
expect(ctxStub.calls[0]).toEqual({ op: 'setTransform', args: [2, 0, 0, 2, 0, 0] });
unmount();
Object.defineProperty(window, 'devicePixelRatio', { configurable: true, get: () => 1 });
});
it('keeps a 1x devicePixelRatio untouched', () => {
Object.defineProperty(window, 'devicePixelRatio', { configurable: true, get: () => 1 });
render(<HeroParticleField />);
const canvas = screen.getByTestId('hero-particle-field') as HTMLCanvasElement;
expect(canvas.width).toBe(VIEWPORT.width);
expect(ctxStub.calls[0]).toEqual({ op: 'setTransform', args: [1, 0, 0, 1, 0, 0] });
});
it('treats a zero devicePixelRatio as 1 instead of collapsing the canvas', () => {
// 部分宿主在缩放计算前上报 dpr=0:Math.min(0, 2)=0 会把位图缩成 0x0,必须回落到 1
Object.defineProperty(window, 'devicePixelRatio', { configurable: true, get: () => 0 });
try {
render(<HeroParticleField />);
const canvas = screen.getByTestId('hero-particle-field') as HTMLCanvasElement;
expect(canvas.width).toBe(VIEWPORT.width);
expect(canvas.style.width).toBe('1200px');
expect(ctxStub.calls[0]).toEqual({ op: 'setTransform', args: [1, 0, 0, 1, 0, 0] });
} finally {
Object.defineProperty(window, 'devicePixelRatio', { configurable: true, get: () => 1 });
}
});
it('scales particle count with area', () => {
render(<HeroParticleField />);
paintOnce();
// 1200x700 / 26000 ≈ 32
expect(arcPositions()).toHaveLength(32);
});
it('caps particle count at 56 on a very large viewport', () => {
setViewport({ width: 4000, height: 4000 });
render(<HeroParticleField />);
paintOnce();
expect(arcPositions()).toHaveLength(56);
});
it('draws nothing extra when the container has zero area', () => {
setViewport({ width: 0, height: 0 });
render(<HeroParticleField />);
paintOnce();
const canvas = screen.getByTestId('hero-particle-field') as HTMLCanvasElement;
// 面积为 0 时不产生粒子,但画布仍保留 1px 下限(避免 canvas 尺寸非法)
expect(canvas.width).toBe(1);
expect(arcPositions()).toHaveLength(0);
expect(written('fillStyle')).toHaveLength(0);
});
});
// ─── 变体绘制 ────────────────────────────────────────────────────────────
describe('HeroParticleField · 变体绘制', () => {
const renderVariant = (variant: HeroVariant, dark = false) => {
const view = render(<HeroParticleField variant={variant} dark={dark} />);
paintOnce();
return view;
};
it('drift paints nodes only — no links, no streams, no glow', () => {
renderVariant('drift');
expect(ctxStub.gradients).toHaveLength(0);
expect(ctxStub.calls.filter((c) => c.op === 'stroke')).toHaveLength(0);
expect(written('shadowColor')).toHaveLength(0);
expect(written('fillStyle').length).toBeGreaterThan(0);
});
it('grid draws thin ink links on a light background', () => {
renderVariant('grid');
expect(written('strokeStyle')).toContain('rgba(10,14,20,1)');
expect(written('shadowColor')).toHaveLength(0);
});
it('network draws white links and brand-red glow only for the bright nodes on dark', () => {
renderVariant('network', true);
expect(written('strokeStyle')).toContain('rgba(255,255,255,1)');
expect(written('shadowColor')).toContain('rgba(196,30,58,0.9)');
expect(written('shadowBlur')).toContain('8');
});
it('spotlight combines links with glow', () => {
renderVariant('spotlight', true);
expect(ctxStub.calls.filter((c) => c.op === 'stroke').length).toBeGreaterThan(0);
expect(written('shadowColor')).toContain('rgba(196,30,58,0.9)');
});
it('constellation adds vertical data streams and dim secondary nodes', () => {
renderVariant('constellation', true);
// 16 条竖向数据流,各用一条线性渐变
expect(ctxStub.gradients).toHaveLength(16);
expect(ctxStub.gradients[0]!.addColorStop).toHaveBeenCalledTimes(3);
const fills = written('fillStyle');
expect(fills.some((f) => f.startsWith('rgba(180,190,205'))).toBe(true); // 暗白次级节点
expect(fills.some((f) => f.startsWith('rgba(196, 30, 58'))).toBe(true); // 品牌红主节点
// 次级节点半径收缩到 0.7 倍,且不做 dim 的每 4 个一取的规则会被固定种子复现
const dimCount = ctxStub.calls.filter((c) => c.op === 'arc').length;
expect(dimCount).toBe(32);
});
it('uses the cool-grey dim node on a light constellation too', () => {
renderVariant('constellation', false);
expect(written('fillStyle').some((f) => f.startsWith('rgba(100,116,139'))).toBe(true);
expect(written('shadowColor')).toHaveLength(0); // 浅底不辉光
});
it('re-derives the variant when the prop changes', () => {
const { rerender } = render(<HeroParticleField variant="drift" />);
paintOnce();
expect(ctxStub.gradients).toHaveLength(0);
const before = ctxStub.calls.length;
rerender(<HeroParticleField variant="constellation" />);
paintOnce();
expect(screen.getByTestId('hero-particle-field')).toHaveAttribute('data-variant', 'constellation');
expect(ctxStub.calls.length).toBeGreaterThan(before);
expect(ctxStub.gradients).toHaveLength(16);
});
});
// ─── 品牌色读取 ──────────────────────────────────────────────────────────
describe('HeroParticleField · 品牌红取值', () => {
it('reads --color-brand-rgb from the document root', () => {
document.documentElement.style.setProperty('--color-brand-rgb', '12 200 40');
render(<HeroParticleField />);
paintOnce();
expect(written('fillStyle')[0]).toContain('rgba(12, 200, 40,');
});
it.each([
['malformed tokens', 'a b c'],
['a partial triple', '12 34'],
])('falls back to the literal brand red for %s', (_label, raw) => {
document.documentElement.style.setProperty('--color-brand-rgb', raw);
render(<HeroParticleField />);
paintOnce();
expect(written('fillStyle')[0]).toContain('rgba(196, 30, 58,');
});
it('falls back when the token is not declared at all', () => {
render(<HeroParticleField />);
paintOnce();
expect(written('fillStyle')[0]).toContain('rgba(196, 30, 58,');
});
});
// ─── 动画循环 ────────────────────────────────────────────────────────────
describe('HeroParticleField · 循环与降级', () => {
it('drives a continuous rAF loop that keeps every node inside the wrap box', () => {
setCanvasClientBox(8, 8); // 视口远小于初始分布 → 第一帧即触发回绕
render(<HeroParticleField />);
expect(rafSpy).toHaveBeenCalledTimes(1);
const frames = runFrames([16, 32, 48, 64, 96, 120, 160, 200]);
expect(frames).toBeGreaterThan(1);
const positions = arcPositions();
const xs = positions.map((p) => p.x);
const ys = positions.map((p) => p.y);
expect(positions.length).toBe(32 * frames);
expect(Math.min(...xs)).toBeGreaterThanOrEqual(-3);
expect(Math.max(...xs)).toBeLessThanOrEqual(11);
expect(Math.min(...ys)).toBeGreaterThanOrEqual(-3);
expect(Math.max(...ys)).toBeLessThanOrEqual(11);
// 两个方向都真的发生了回绕:右出界 → 左侧 -3 入场,左出界 → 右侧 w+3 入场
expect(xs).toContain(-3);
expect(xs).toContain(11);
expect(ys).toContain(-3);
expect(ys).toContain(11);
});
it('falls back to the backing-store box while the canvas has no layout size', () => {
// 首帧尚未排版时 clientWidth/Height 会是 0:回绕与淡出必须改用位图尺寸,而不是被 0x0 挤到边界
setCanvasClientBox(0, 0);
render(<HeroParticleField />);
paintOnce();
const positions = arcPositions();
const xs = positions.map((p) => p.x);
const ys = positions.map((p) => p.y);
expect(positions).toHaveLength(32);
expect(Math.max(...xs) - Math.min(...xs)).toBeGreaterThan(600);
expect(Math.max(...ys) - Math.min(...ys)).toBeGreaterThan(300);
expect(Math.max(...xs)).toBeLessThanOrEqual(VIEWPORT.width + 3);
expect(Math.max(...ys)).toBeLessThanOrEqual(VIEWPORT.height + 3);
});
it('cancels the scheduled frame on unmount', () => {
const { unmount } = render(<HeroParticleField />);
runFrames([16]);
unmount();
expect(cafSpy).toHaveBeenCalled();
});
it('paints a single static frame and never schedules rAF under reduced motion', () => {
setReduceMotion(true);
render(<HeroParticleField />);
expect(rafSpy).not.toHaveBeenCalled();
expect(ctxStub.calls.filter((c) => c.op === 'fill')).toHaveLength(32);
setReduceMotion(false);
});
it('paints a single static frame in automated browsers (navigator.webdriver)', () => {
setWebdriver(true);
render(<HeroParticleField />);
expect(rafSpy).not.toHaveBeenCalled();
expect(arcPositions()).toHaveLength(32);
// 静态帧仍要落笔:边缘淡出后的透明度写入了 fillStyle
expect(written('fillStyle').length).toBeGreaterThan(0);
});
it('degrades to a static frame when requestAnimationFrame is unavailable', () => {
const savedRaf = window.requestAnimationFrame;
// @ts-expect-error 运行期删除,模拟无 rAF 的老宿主
delete window.requestAnimationFrame;
try {
render(<HeroParticleField />);
expect(arcPositions()).toHaveLength(32);
expect(rafSpy).not.toHaveBeenCalled();
} finally {
// `writable` 必须显式给出:defineProperty 的默认值是 false,缺省会把它变成只读属性,
// 随后 afterEach 里 rafSpy.mockRestore() 的赋值就会抛
// "Cannot assign to read only property 'requestAnimationFrame'",整套件判为 failed to run。
Object.defineProperty(window, 'requestAnimationFrame', {
configurable: true,
writable: true,
value: savedRaf,
});
}
});
it('stops when the tab is hidden and restarts when it becomes visible', () => {
render(<HeroParticleField />);
const rafCallsBefore = rafSpy.mock.calls.length;
const visibility = Object.getOwnPropertyDescriptor(Document.prototype, 'visibilityState')
?? Object.getOwnPropertyDescriptor(document, 'visibilityState');
Object.defineProperty(document, 'visibilityState', { configurable: true, get: () => 'hidden' });
document.dispatchEvent(new Event('visibilitychange'));
expect(cafSpy).toHaveBeenCalled();
expect(rafSpy.mock.calls.length).toBe(rafCallsBefore);
Object.defineProperty(document, 'visibilityState', { configurable: true, get: () => 'visible' });
document.dispatchEvent(new Event('visibilitychange'));
expect(rafSpy.mock.calls.length).toBeGreaterThan(rafCallsBefore);
if (visibility) Object.defineProperty(document, 'visibilityState', visibility);
});
it('still runs the loop on hosts without IntersectionObserver and unmounts cleanly', () => {
// 老宿主缺 IO:引擎要直接按挂载即起跑,卸载时的 io?.disconnect() 也不能抛错
const savedIO = (globalThis as Record<string, unknown>).IntersectionObserver;
delete (globalThis as Record<string, unknown>).IntersectionObserver;
try {
const { unmount } = render(<HeroParticleField />);
expect(rafSpy).toHaveBeenCalledTimes(1);
paintOnce();
expect(arcPositions()).toHaveLength(32);
expect(() => unmount()).not.toThrow();
expect(cafSpy).toHaveBeenCalled();
} finally {
(globalThis as Record<string, unknown>).IntersectionObserver = savedIO;
}
});
it('rebuilds and repaints through ResizeObserver when the host provides one', () => {
const observers: Array<{ cb: () => void; targets: Element[]; disconnected: boolean }> = [];
class MockResizeObserver {
cb: () => void;
targets: Element[] = [];
disconnected = false;
constructor(cb: () => void) {
this.cb = cb;
observers.push(this);
}
observe(el: Element) {
this.targets.push(el);
}
unobserve() {}
disconnect() {
this.disconnected = true;
}
}
(globalThis as Record<string, unknown>).ResizeObserver = MockResizeObserver;
render(<HeroParticleField />);
const canvas = screen.getByTestId('hero-particle-field') as HTMLCanvasElement;
expect(canvas.width).toBe(1200);
const observer = observers[0];
expect(observer?.targets).toHaveLength(1);
setViewport({ width: 800, height: 600 });
observer!.cb();
// 重建:位图尺寸与变换矩阵按新容器重排(800x600 / 26000 ≈ 18 个粒子)
expect(canvas.width).toBe(800);
expect(canvas.height).toBe(600);
expect(ctxStub.calls.filter((c) => c.op === 'setTransform')).toHaveLength(2);
runFrames([16]);
expect(arcPositions()).toHaveLength(18);
});
it('disconnects the observers on unmount', () => {
const observers: Array<{ disconnected: boolean }> = [];
class MockResizeObserver {
disconnected = false;
constructor(cb: () => void) {
void cb;
observers.push(this);
}
observe() {}
unobserve() {}
disconnect() {
this.disconnected = true;
}
}
(globalThis as Record<string, unknown>).ResizeObserver = MockResizeObserver;
const { unmount } = render(<HeroParticleField />);
unmount();
expect(observers[0]?.disconnected).toBe(true);
});
it('appends a custom class to the canvas layer', () => {
render(<HeroParticleField className="hero-overlay" />);
const canvas = screen.getByTestId('hero-particle-field');
expect(canvas.className).toContain('hero-overlay');
expect(canvas.className).toContain('pointer-events-none');
});
});
@@ -1,79 +0,0 @@
import { describe, it, expect, jest } from '@jest/globals';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import HeroParticleField from './hero-particle-field';
jest.mock('@/hooks/use-reduced-motion', () => ({
useReducedMotion: jest.fn(() => false),
}));
describe('HeroParticleField - 动态粒子层(循环漂移动画)', () => {
it('renders an aria-hidden, non-interactive canvas layer', () => {
render(<HeroParticleField />);
const canvas = screen.getByTestId('hero-particle-field');
expect(canvas.tagName).toBe('CANVAS');
expect(canvas).toHaveAttribute('aria-hidden', 'true');
expect(canvas.className).toContain('pointer-events-none');
});
it('does not throw under reduced motion (degrades to a single static frame)', () => {
const { useReducedMotion } = require('@/hooks/use-reduced-motion');
(useReducedMotion as jest.Mock).mockReturnValue(true);
expect(() => render(<HeroParticleField />)).not.toThrow();
// 静态降级下仍渲染 canvas(无 rAF 循环,仅一次绘制)
expect(screen.getByTestId('hero-particle-field').tagName).toBe('CANVAS');
});
it('bails safely when no 2d context is available (jsdom / SSR guard)', () => {
const ctxSpy = jest
.spyOn(HTMLCanvasElement.prototype, 'getContext')
.mockReturnValue(null as any);
expect(() => render(<HeroParticleField />)).not.toThrow();
ctxSpy.mockRestore();
});
it('starts a continuous rAF loop and stops it on unmount when animation is allowed', () => {
// 重置被前置用例 mockReturnValue(true) 污染的共享 mock,确保本用例走动画路径
const { useReducedMotion: urm } = require('@/hooks/use-reduced-motion');
(urm as jest.Mock).mockReturnValue(false);
const ctxStub = {
setTransform: jest.fn(),
clearRect: jest.fn(),
beginPath: jest.fn(),
arc: jest.fn(),
fill: jest.fn(),
fillStyle: '',
};
const getCtxSpy = jest
.spyOn(HTMLCanvasElement.prototype, 'getContext')
.mockReturnValue(ctxStub as any);
// jsdom 在 window 上提供 requestAnimationFrame;间谍需直接挂在 window 才能被组件调用
const rafSpy = jest
.spyOn(window, 'requestAnimationFrame')
.mockImplementation(() => 1 as unknown as number);
const cafSpy = jest
.spyOn(window, 'cancelAnimationFrame')
.mockImplementation(() => undefined);
// 强制非自动化环境,确保走动画路径(而非 navigator.webdriver 静态降级)
try {
Object.defineProperty(navigator, 'webdriver', {
configurable: true,
get: () => false,
});
} catch {
/* navigator.webdriver 不可重定义时忽略,依赖 rAF 间谍仍应触发循环 */
}
const { unmount } = render(<HeroParticleField />);
// 动画路径:应已调度 rAF(持续循环起点),且 navigator.webdriver 未触发静态降级
expect(rafSpy).toHaveBeenCalled();
unmount();
expect(cafSpy).toHaveBeenCalled();
getCtxSpy.mockRestore();
rafSpy.mockRestore();
cafSpy.mockRestore();
});
});
@@ -1,325 +0,0 @@
'use client';
/**
* Hero 动态粒子层(循环漂移动画 + 科技感变体)
*
* 设计约束对齐(CLAUDE.md / CONTEXT.md / Impeccable 审计):
* - 循环动画(用户特批豁免「无持续循环」铁律):rAF 持续漂移,离屏/隐藏标签页即停。
* - 品牌红单电压:粒子用 --color-brand-rgb(#C41E3A),稀疏小点(封顶 56、半径 ≤2.6px),
* 品牌红面积占比 <0.1%,远低于单电压 10% 上限,不作为大背景。
* - reduced-motion:直接绘制一次静态帧,不进入 rAF 循环。
* - 自动化环境稳定:navigator.webdriver 为真(Playwright 默认)时同样降级为静态帧,
* 且位置由固定种子 mulberry32 复现——与改动前「入场后静止」的冻结帧像素一致,
* 因此视觉回归快照基线不发生漂移(连线/星图位置同样由固定种子复现)。
* - 性能:DPR 限幅(≤2)、粒子数随面积封顶、离屏/隐藏即停、ResizeObserver 重排。
* - 无特效库:纯自包含 canvas,不引入任何第三方动画/粒子依赖(effects/ 已删除)。
*
* 变体(variant prop,默认 'drift' 兼容旧调用):
* - 'drift' 仅品牌红小点漂移(原行为,浅色 Hero 用)
* - 'grid' 浅色科技感:墨色细连线 + 品牌红节点(网格由 HeroSection 的 CSS 层承担)
* - 'network' 品牌红节点 + 邻近中性灰连线(深色 Hero 默认,科技感最强)
* - 'constellation' 品牌红脉冲节点 + 暗白次级点 + 极淡竖向数据流(NovaVis 看板语义)
* - 'spotlight' 同 network + 工程网格 + 品牌红光标聚光(纵深最强)
* 连线/辉光仅作用于深色底(dark=true);浅色变体用墨色细线。
*/
import { useEffect, useRef } from 'react';
import { useReducedMotion } from '@/hooks/use-reduced-motion';
const MAX_DPR = 2;
const MAX_PARTICLES = 56;
const DENSITY_DIVISOR = 26000; // 每 ~26000px² 一个粒子,面积驱动密度封顶
const SEED = 0x9e3779b9; // 固定种子 → 初始位置可复现(快照稳定)
const BASE_SPEED = 0.25; // px / 16ms,极缓漂移
const LINK_DIST = 150; // 连线触发距离
export type HeroVariant = 'drift' | 'network' | 'grid' | 'constellation' | 'spotlight';
interface VariantConfig {
links: boolean; // 邻近粒子连线
glow: boolean; // 品牌红节点辉光(仅深底生效)
dim: boolean; // 暗白次级节点(星图)
streams: boolean; // 竖向数据流
}
const VARIANT_CONFIG: Record<HeroVariant, VariantConfig> = {
drift: { links: false, glow: false, dim: false, streams: false },
// grid:浅色科技感变体 —— 墨色细连线 + 品牌红节点(工程网格由 HeroSection 的 CSS 层承担)
grid: { links: true, glow: false, dim: false, streams: false },
network: { links: true, glow: true, dim: false, streams: false },
constellation: { links: false, glow: true, dim: true, streams: true },
spotlight: { links: true, glow: true, dim: false, streams: false },
};
interface Particle {
x: number;
y: number;
vx: number;
vy: number;
r: number;
alpha: number;
dim: boolean;
}
function readBrandRgb(): [number, number, number] {
if (typeof window === 'undefined') return [196, 30, 58];
const raw = getComputedStyle(document.documentElement)
.getPropertyValue('--color-brand-rgb')
.trim();
if (raw) {
const parts = raw.split(/\s+/).map(Number);
if (parts.length === 3 && parts.every((n) => !Number.isNaN(n))) {
const [r, g, b] = parts as [number, number, number];
return [r, g, b];
}
}
return [196, 30, 58];
}
/** 固定种子 PRNG(mulberry32):让粒子位置对给定视口可复现,避免视觉回归快照 flaky */
function mulberry32(seed: number): () => number {
let s = seed;
return function () {
s |= 0;
s = (s + 0x6d2b79f5) | 0;
let t = Math.imul(s ^ (s >>> 15), 1 | s);
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
export function HeroParticleField({
variant = 'drift',
dark = false,
className,
}: {
variant?: HeroVariant;
dark?: boolean;
className?: string;
}) {
const canvasRef = useRef<HTMLCanvasElement>(null);
const reduceMotion = useReducedMotion();
useEffect(() => {
const canvas = canvasRef.current;
if (!canvas) return;
const ctx = canvas.getContext('2d');
if (!ctx) return; // jsdom / SSR / 无 2d 上下文:安全退出,不绘制
const parent = canvas.parentElement;
if (!parent) return;
// 变体配置在 effect 内派生:随 variant 重建(VARIANT_CONFIG 为模块级常量,无需入依赖数组)
const cfg = VARIANT_CONFIG[variant];
const brand = readBrandRgb();
let particles: Particle[] = [];
let raf = 0;
let last = 0;
let running = false;
const hasRaf = typeof requestAnimationFrame === 'function';
// Playwright 默认将 navigator.webdriver 置 true → 降级静态帧,保证快照稳定
const isAutomation =
typeof navigator !== 'undefined' &&
(navigator as unknown as { webdriver?: boolean }).webdriver === true;
const paint = () => {
// 透明画布:仅绘制粒子层,背景由 section 承载(支持深色/浅色 Hero 切换)
ctx.clearRect(0, 0, canvas.width, canvas.height);
const w = canvas.clientWidth || canvas.width;
const h = canvas.clientHeight || canvas.height;
// 边缘径向淡出:中心可见、四角收敛(确定性 —— 仅依赖固定种子位置 + 视口尺寸,快照零漂移)
const maxR = Math.max(1, Math.hypot(w / 2, h / 2));
const fade = (x: number, y: number) => {
const d = Math.hypot(x - w / 2, y - h / 2) / maxR;
return 0.2 + 0.8 * Math.max(0, 1 - d);
};
// 竖向数据流(constellation):固定种子复现 x 位置 → 静态降级像素稳定
if (cfg.streams) {
const srng = mulberry32(SEED ^ 0x55);
ctx.lineWidth = 1;
for (let i = 0; i < 16; i++) {
const x = srng() * w;
const g = ctx.createLinearGradient(0, 0, 0, h);
g.addColorStop(0, 'rgba(196,30,58,0)');
g.addColorStop(0.5, 'rgba(196,30,58,0.06)');
g.addColorStop(1, 'rgba(196,30,58,0)');
ctx.strokeStyle = g;
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, h);
ctx.stroke();
}
}
// 邻近连线(network / spotlight):中性灰(深底)或墨色(浅底),不抢品牌红
if (cfg.links && particles.length) {
ctx.lineWidth = 1;
for (let i = 0; i < particles.length; i++) {
const a = particles[i];
if (!a) continue; // noUncheckedIndexedAccess 收窄(不用非空断言,避免 lint 告警)
for (let j = i + 1; j < particles.length; j++) {
const b = particles[j];
if (!b) continue;
const dx = a.x - b.x;
const dy = a.y - b.y;
const d = Math.hypot(dx, dy);
if (d < LINK_DIST) {
ctx.strokeStyle = dark ? 'rgba(255,255,255,1)' : 'rgba(10,14,20,1)';
// 浅底连线更克制:上限 0.42(原 0.7)+ 边缘径向淡出,避免「图纸过密」
ctx.globalAlpha = (1 - d / LINK_DIST) * 0.42 * fade((a.x + b.x) / 2, (a.y + b.y) / 2);
ctx.beginPath();
ctx.moveTo(a.x, a.y);
ctx.lineTo(b.x, b.y);
ctx.stroke();
}
}
}
ctx.globalAlpha = 1;
}
// 粒子节点
for (const p of particles) {
if (dark && cfg.glow && !p.dim) {
ctx.shadowColor = 'rgba(196,30,58,0.9)';
ctx.shadowBlur = 8;
} else {
ctx.shadowBlur = 0;
}
// 边缘径向淡出同样作用于节点,使视线聚焦版心
const na = (p.dim ? (dark ? 0.4 : 0.5) : p.alpha) * fade(p.x, p.y);
ctx.fillStyle = p.dim
? `rgba(${dark ? '180,190,205' : '100,116,139'}, ${na})`
: `rgba(${brand[0]}, ${brand[1]}, ${brand[2]}, ${na})`;
ctx.beginPath();
ctx.arc(p.x, p.y, p.dim ? p.r * 0.7 : p.r, 0, Math.PI * 2);
ctx.fill();
}
ctx.shadowBlur = 0;
};
const build = () => {
const rect = parent.getBoundingClientRect();
const dpr = Math.min(window.devicePixelRatio || 1, MAX_DPR);
canvas.width = Math.max(1, Math.floor(rect.width * dpr));
canvas.height = Math.max(1, Math.floor(rect.height * dpr));
canvas.style.width = `${rect.width}px`;
canvas.style.height = `${rect.height}px`;
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
const area = rect.width * rect.height;
const count = Math.min(MAX_PARTICLES, Math.round(area / DENSITY_DIVISOR));
const rng = mulberry32(SEED); // 固定种子 → 位置可复现(含 dim 标记不消耗额外 rng)
particles = Array.from({ length: Math.max(0, count) }, (_, i) => {
const ang = rng() * Math.PI * 2;
const sp = BASE_SPEED * (0.5 + rng());
return {
x: rng() * rect.width,
y: rng() * rect.height,
vx: Math.cos(ang) * sp,
vy: Math.sin(ang) * sp,
r: 0.8 + rng() * 1.8,
alpha: 0.35 + rng() * 0.5,
// dim 次级节点:确定性派生(不消耗 rng),保证各变体粒子位置一致
dim: cfg.dim && i % 4 === 1,
};
});
};
// 单帧推进:dt 归一化到 ~60fps,出界回绕(toroidal wrap)
const step = (now: number) => {
const dt = last ? Math.min(48, now - last) : 16.67;
last = now;
const k = dt / 16.67;
const w = canvas.clientWidth || canvas.width;
const h = canvas.clientHeight || canvas.height;
for (const p of particles) {
p.x += p.vx * k;
p.y += p.vy * k;
if (p.x < -3) p.x = w + 3;
else if (p.x > w + 3) p.x = -3;
if (p.y < -3) p.y = h + 3;
else if (p.y > h + 3) p.y = -3;
}
paint();
if (running && hasRaf) raf = requestAnimationFrame(step);
};
const start = () => {
if (running || !hasRaf) return;
running = true;
last = 0;
raf = requestAnimationFrame(step);
};
const stop = () => {
running = false;
if (raf) {
cancelAnimationFrame(raf);
raf = 0;
}
};
build();
// 静态降级:reduced-motion / 自动化环境 / 无 rAF(如 jsdom)
if (reduceMotion || isAutomation || !hasRaf) {
paint();
} else {
start();
}
// 离屏或标签页隐藏即停,回到视口且可见再启动
let io: IntersectionObserver | undefined;
// 记录是否仍在视口内;onVisibility 须同时满足「可见 + 在视口」才启动,
// 否则滚出视口后切走标签页再切回,会在离屏 canvas 上把 rAF 空转起来(S-8,违背 :271 契约)。
let intersecting = true;
if (typeof IntersectionObserver !== 'undefined') {
io = new IntersectionObserver(
(entries) => {
const visible = entries.some((e) => e.isIntersecting);
intersecting = visible;
if (visible && document.visibilityState === 'visible' && !reduceMotion && !isAutomation) {
start();
} else {
stop();
}
},
{ threshold: 0.01 },
);
io.observe(canvas);
}
const onVisibility = () => {
if (document.visibilityState !== 'visible') stop();
else if (intersecting && !reduceMotion && !isAutomation) start();
};
document.addEventListener('visibilitychange', onVisibility);
let ro: ResizeObserver | undefined;
if (typeof ResizeObserver !== 'undefined') {
ro = new ResizeObserver(() => {
build();
if (reduceMotion || isAutomation || !hasRaf) paint();
});
ro.observe(parent);
}
return () => {
stop();
io?.disconnect();
ro?.disconnect();
document.removeEventListener('visibilitychange', onVisibility);
};
}, [reduceMotion, variant, dark]);
return (
<canvas
ref={canvasRef}
data-testid="hero-particle-field"
data-variant={variant}
aria-hidden="true"
className={`absolute inset-0 pointer-events-none ${className ?? ''}`}
/>
);
}
export default HeroParticleField;
@@ -1,91 +0,0 @@
// @ts-nocheck
import { describe, it, expect, jest } from '@jest/globals';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
// ─── Mocks ───────────────────────────────────────────────────────────────
jest.mock('framer-motion', () => ({
motion: {
div: ({ children, initial, animate, variants, whileInView, className, ...props }: any) => (
<div
data-testid="motion-div"
data-initial={JSON.stringify(initial)}
data-animate={JSON.stringify(animate)}
data-variants={JSON.stringify(variants)}
data-while-inview={JSON.stringify(whileInView)}
className={className}
{...props}
>
{children}
</div>
),
},
useInView: jest.fn(() => true),
AnimatePresence: ({ children }: any) => <>{children}</>,
}));
// ─── Mock Data ────────────────────────────────────────────────────────────
const FactoryIcon = () => <svg data-testid="icon-factory" className="w-7 h-7" />;
const RetailIcon = () => <svg data-testid="icon-retail" className="w-7 h-7" />;
const EducationIcon = () => <svg data-testid="icon-education" className="w-7 h-7" />;
const HealthcareIcon = () => <svg data-testid="icon-healthcare" className="w-7 h-7" />;
const mockItems = [
{ icon: FactoryIcon, name: '制造业', count: '12个案例' },
{ icon: RetailIcon, name: '贸易零售', count: '8个案例' },
{ icon: EducationIcon, name: '教育培训', count: '6个案例' },
{ icon: HealthcareIcon, name: '医疗健康', count: '5个案例' },
];
// ─── Tests ───────────────────────────────────────────────────────────────
describe('IndustryGrid', () => {
it('should render all industry items', async () => {
const { IndustryGrid } = await import('./industry-grid');
render(<IndustryGrid items={mockItems} />);
expect(screen.getByText('制造业')).toBeInTheDocument();
expect(screen.getByText('贸易零售')).toBeInTheDocument();
expect(screen.getByText('教育培训')).toBeInTheDocument();
expect(screen.getByText('医疗健康')).toBeInTheDocument();
});
it('should render case counts', async () => {
const { IndustryGrid } = await import('./industry-grid');
render(<IndustryGrid items={mockItems} />);
expect(screen.getByText('12个案例')).toBeInTheDocument();
expect(screen.getByText('8个案例')).toBeInTheDocument();
expect(screen.getByText('6个案例')).toBeInTheDocument();
expect(screen.getByText('5个案例')).toBeInTheDocument();
});
it('should render icons for each item', async () => {
const { IndustryGrid } = await import('./industry-grid');
render(<IndustryGrid items={mockItems} />);
expect(screen.getByTestId('icon-factory')).toBeInTheDocument();
expect(screen.getByTestId('icon-retail')).toBeInTheDocument();
expect(screen.getByTestId('icon-education')).toBeInTheDocument();
expect(screen.getByTestId('icon-healthcare')).toBeInTheDocument();
});
it('should render with role="button" and tabIndex={0}', async () => {
const { IndustryGrid } = await import('./industry-grid');
render(<IndustryGrid items={mockItems.slice(0, 1)} />);
const item = screen.getByRole('button');
expect(item).toHaveAttribute('tabindex', '0');
});
it('should apply custom className', async () => {
const { IndustryGrid } = await import('./industry-grid');
const { container } = render(<IndustryGrid items={mockItems} className="custom-grid" />);
const grid = container.querySelector('.custom-grid');
expect(grid).toBeInTheDocument();
});
it('should render empty grid when items is empty', async () => {
const { IndustryGrid } = await import('./industry-grid');
const { container } = render(<IndustryGrid items={[]} />);
expect(container.querySelector('[role="button"]')).not.toBeInTheDocument();
});
});
-46
View File
@@ -1,46 +0,0 @@
'use client';
import { type ElementType } from 'react';
interface IndustryItem {
icon: ElementType;
name: string;
count: string;
href?: string;
}
interface IndustryGridProps {
items: IndustryItem[];
className?: string;
}
export function IndustryGrid({ items, className = '' }: IndustryGridProps) {
return (
<div
className={`grid grid-cols-2 sm:grid-cols-4 gap-px rounded-sm overflow-hidden ${className}`}
style={{ background: 'var(--color-border-secondary)' }}
>
{items.map((item, i) => {
const Icon = item.icon;
return (
<div
key={i}
className="group relative overflow-hidden py-8 sm:py-10 px-4 sm:px-6 text-center cursor-pointer transition-all duration-150 bg-[var(--color-bg-primary)] hover:bg-[var(--color-bg-secondary)]"
role="button"
tabIndex={0}
>
<div className="relative z-10">
<Icon className="w-7 h-7 sm:w-8 sm:h-8 mx-auto mb-2 sm:mb-3 transition-transform duration-150 group-hover:scale-110 text-[var(--color-text-primary)] group-hover:text-brand-ink" />
<div className="text-[13px] sm:text-[14px] font-medium transition-colors duration-150 text-[var(--color-text-primary)] group-hover:text-brand-ink">
{item.name}
</div>
<div className="text-[10px] sm:text-[11px] mt-1 sm:mt-1.5 transition-colors duration-150 text-[var(--color-text-subtle)] group-hover:text-[var(--color-text-muted)]">
{item.count}
</div>
</div>
</div>
);
})}
</div>
);
}
@@ -1,98 +0,0 @@
// @ts-nocheck
import { describe, it, expect, jest } from '@jest/globals';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
// ─── Mocks ───────────────────────────────────────────────────────────────
jest.mock('framer-motion', () => ({
motion: {
div: ({ children, initial, animate, variants, whileInView, whileHover, viewport, transition, className, ...props }: any) => (
<div
data-testid="motion-div"
data-initial={JSON.stringify(initial)}
data-animate={JSON.stringify(animate)}
data-variants={JSON.stringify(variants)}
data-while-hover={JSON.stringify(whileHover)}
data-while-inview={JSON.stringify(whileInView)}
data-viewport={JSON.stringify(viewport)}
data-transition={JSON.stringify(transition)}
className={className}
{...props}
>
{children}
</div>
),
},
useInView: jest.fn(() => true),
AnimatePresence: ({ children }: any) => <>{children}</>,
}));
jest.mock('lucide-react', () => ({
ArrowUpRight: (props: any) => <svg data-testid="icon-arrow-up-right" className={props.className} />,
}));
// ─── Mock Data ────────────────────────────────────────────────────────────
const mockInsight = {
tag: '白皮书',
title: '2025年数字化转型趋势',
desc: '深入分析企业数字化转型的最新趋势与挑战',
date: '2025年1月',
};
// ─── Tests ───────────────────────────────────────────────────────────────
describe('InsightCard', () => {
it('should render tag, title, and description', async () => {
const { InsightCard } = await import('./insight-card');
render(<InsightCard {...mockInsight} />);
expect(screen.getByText('白皮书')).toBeInTheDocument();
expect(screen.getByText('2025年数字化转型趋势')).toBeInTheDocument();
expect(screen.getByText('深入分析企业数字化转型的最新趋势与挑战')).toBeInTheDocument();
});
it('should render date when provided', async () => {
const { InsightCard } = await import('./insight-card');
render(<InsightCard {...mockInsight} />);
expect(screen.getByText('2025年1月')).toBeInTheDocument();
});
it('should not render date when not provided', async () => {
const { InsightCard } = await import('./insight-card');
render(<InsightCard {...mockInsight} date={undefined} />);
expect(screen.queryByText('2025年1月')).not.toBeInTheDocument();
});
it('should render "阅读全文" for featured variant', async () => {
const { InsightCard } = await import('./insight-card');
render(<InsightCard {...mockInsight} featured />);
expect(screen.getByText('阅读全文')).toBeInTheDocument();
});
it('should render background image for featured variant', async () => {
const { InsightCard } = await import('./insight-card');
const { container } = render(
<InsightCard {...mockInsight} featured image="/images/insights/trends.jpg" />
);
// 组件用 CSS 背景图而非 <img>,使 404 图片静默降级为纯色底
const bg = container.querySelector('[style*="background-image"]');
expect(bg).toBeInTheDocument();
expect(bg).toHaveAttribute('aria-hidden', 'true');
expect(bg).toHaveStyle({ backgroundImage: 'url(/images/insights/trends.jpg)' });
});
it('should render link element when provided', async () => {
const { InsightCard } = await import('./insight-card');
render(<InsightCard {...mockInsight} link={<span data-testid="custom-link">查看更多</span>} />);
expect(screen.getByTestId('custom-link')).toBeInTheDocument();
expect(screen.getByText('查看更多')).toBeInTheDocument();
});
it('should apply custom className', async () => {
const { InsightCard } = await import('./insight-card');
const { container } = render(<InsightCard {...mockInsight} className="custom-card" />);
const card = container.querySelector('.custom-card');
expect(card).toBeInTheDocument();
});
});
-90
View File
@@ -1,90 +0,0 @@
'use client';
import { type ReactNode } from 'react';
import { ArrowUpRight } from 'lucide-react';
interface InsightCardProps {
/** Category tag (e.g. "白皮书", "观点") */
tag: string;
/** Title */
title: string;
/** Description */
desc: string;
/** Optional date string */
date?: string;
/** Whether this is a featured (large) card with image */
featured?: boolean;
/** Image URL for featured card */
image?: string;
/** Optional link element (avoid nesting <a> in <a>) */
link?: ReactNode;
className?: string;
}
export function InsightCard({
tag,
title,
desc,
date,
featured = false,
image,
link,
className = '',
}: InsightCardProps) {
if (featured) {
return (
<div
className={`group relative overflow-hidden flex flex-col justify-end min-h-[260px] sm:min-h-[300px] md:min-h-[360px] p-8 sm:p-10 md:p-12 lg:p-14 rounded-sm cursor-pointer bg-[var(--color-bg-secondary)] border border-[var(--color-border-primary)] hover:bg-[var(--color-bg-tertiary)] ${className}`}
>
{/* Background image */}
{image && (
<div
aria-hidden="true"
style={{ backgroundImage: `url(${image})` }}
className="absolute inset-0 bg-cover bg-center transition-transform duration-150 group-hover:scale-105 opacity-10"
/>
)}
<div className="relative z-10">
<div className="text-[10px] tracking-[3px] uppercase font-medium mb-4 md:mb-5"
style={{ color: 'var(--color-brand)' }}>
{tag}
</div>
<h3 className="font-sans text-[20px] sm:text-[24px] md:text-[26px] font-bold leading-[1.3] text-[var(--color-text-primary)] mb-2 md:mb-3">
{title}
</h3>
<p className="text-[13px] sm:text-[14px] leading-relaxed max-w-[400px] mb-5 md:mb-6 text-[var(--color-text-secondary)]">
{desc}
</p>
<span className="text-[12px] inline-flex items-center gap-1.5 transition-colors duration-normal text-[var(--color-text-muted)] group-hover:text-brand-ink">
阅读全文
<ArrowUpRight className="w-3 h-3" />
</span>
</div>
</div>
);
}
return (
<div
className={`group p-6 sm:p-8 md:p-10 transition-all duration-150 cursor-pointer flex flex-col bg-[var(--color-bg-primary)] hover:bg-[var(--color-bg-secondary)] ${className}`}
>
<div className="text-[10px] tracking-[2px] uppercase font-medium mb-3 md:mb-4"
style={{ color: 'var(--color-brand)' }}>
{tag}
</div>
<h4 className="font-sans text-[16px] sm:text-[17px] font-semibold leading-[1.5] mb-2 text-[var(--color-text-primary)]">
{title}
</h4>
<p className="text-[13px] leading-relaxed flex-1 mb-4 md:mb-5 text-[var(--color-text-muted)]">
{desc}
</p>
<div className="flex items-center justify-between">
{date && (
<span className="text-[11px] text-[var(--color-text-subtle)]">{date}</span>
)}
{link && <span className="text-[12px] text-[var(--color-text-subtle)]">{link}</span>}
</div>
</div>
);
}
@@ -1,89 +0,0 @@
'use client';
import { motion } from 'framer-motion';
import { useInView } from 'framer-motion';
import { useRef } from 'react';
import { METHODOLOGY } from '@/lib/constants/methodology';
import { CheckCircle2 } from 'lucide-react';
import { Card } from '@/components/ui/card';
const phaseBgOpacities = [0.1, 0.08, 0.12, 0.06];
export function MethodologySection() {
const ref = useRef(null);
const isInView = useInView(ref, { once: true, margin: '-100px' });
return (
<section id="methodology" role="region" aria-labelledby="methodology-heading" className="py-20 md:py-28 bg-[var(--color-bg-section)]" ref={ref}>
<div className="container-wide">
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={isInView ? { opacity: 1, y: 0 } : {}}
transition={{ duration: 0.28, ease: [0.16, 1, 0.3, 1] }}
className="text-center max-w-3xl mx-auto mb-14"
>
<h2 id="methodology-heading" className="text-3xl sm:text-4xl font-semibold text-[var(--color-text-primary)] mb-4">
实施<span className="text-brand-ink">方法论</span>
</h2>
<p className="text-base text-[var(--color-text-muted)]">
经过核心团队实践打磨的四阶段模型,确保每个项目都能科学推进、高效落地
</p>
</motion.div>
<div className="relative">
<div className="hidden lg:block absolute top-16 left-[12.5%] right-[12.5%] h-px bg-gradient-to-r from-transparent via-[var(--color-border-primary)] to-transparent" />
<div className="hidden md:block lg:hidden absolute left-[calc(50%+0.375rem)] top-0 bottom-0 w-px bg-[var(--color-border-primary)]" />
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 md:gap-8">
{METHODOLOGY.map((phase, idx) => {
const bgOpacity = phaseBgOpacities[idx % phaseBgOpacities.length];
return (
<Card
key={phase.id}
className="relative overflow-hidden transition-all duration-normal hover:-translate-y-1 hover:shadow-lg"
>
<div className="p-6 md:p-8">
<div
className="w-10 h-10 rounded-full flex items-center justify-center mb-5 text-sm font-bold"
style={{ backgroundColor: `rgba(var(--color-brand-rgb), ${bgOpacity})`, color: 'var(--color-brand)' }}
>
{phase.number}
</div>
<h3 className="text-lg font-semibold text-[var(--color-text-primary)] mb-1">{phase.title}</h3>
<p className="text-xs text-brand-ink font-medium mb-3">{phase.subtitle}</p>
<p className="text-sm text-[var(--color-text-muted)] leading-relaxed mb-5">{phase.description}</p>
<div className="mb-4">
<p className="text-xs font-semibold text-[var(--color-text-primary)] mb-2 tracking-wide">核心活动</p>
<ul className="space-y-1.5">
{phase.activities.map((activity, i) => (
<li key={i} className="flex items-start gap-2 text-xs text-[var(--color-text-muted)]">
<CheckCircle2 className="w-3.5 h-3.5 text-brand-ink mt-0.5 shrink-0" />
{activity}
</li>
))}
</ul>
</div>
<div>
<p className="text-xs font-semibold text-[var(--color-text-primary)] mb-2 tracking-wide">交付物</p>
<ul className="space-y-1.5">
{phase.deliverables.map((deliverable, i) => (
<li key={i} className="flex items-start gap-2 text-xs text-[var(--color-text-subtle)]">
<span className="w-1.5 h-1.5 bg-brand/40 rounded-full mt-1.5 shrink-0" />
{deliverable}
</li>
))}
</ul>
</div>
</div>
</Card>
);
})}
</div>
</div>
</div>
</section>
);
}
-83
View File
@@ -1,83 +0,0 @@
'use client';
import { type ReactNode } from 'react';
import { StaticLink } from '@/components/ui/static-link';
import { ArrowRight } from 'lucide-react';
interface ProductCardProps {
/** Icon component to render */
icon: ReactNode;
/** Product name */
title: string;
/** One-line description */
description: string;
/** Link href */
href: string;
/** Optional badge label */
badge?: string;
className?: string;
}
export function ProductCard({
icon,
title,
description,
href,
badge,
className = '',
}: ProductCardProps) {
return (
<StaticLink
href={href}
className={`group relative block p-6 sm:p-8 lg:p-10 bg-[var(--color-bg-primary)] border border-[var(--color-border-primary)] rounded-sm transition-all duration-normal overflow-hidden ${className}`}
style={{ minHeight: '44px', minWidth: '44px' }}
>
{/* Left accent bar — visible on hover */}
<div
className="absolute left-0 top-0 bottom-0 w-[3px] bg-[var(--color-brand)] transition-transform duration-normal origin-top"
style={{ transform: 'scaleY(0)' }}
onMouseEnter={(e) => {
e.currentTarget.style.transform = 'scaleY(1)';
}}
/>
{/* Content */}
<div className="relative z-10">
{/* Icon: 装饰性图标,对屏幕阅读器隐藏 */}
<div className="w-10 h-10 sm:w-12 sm:h-12 rounded-lg bg-[var(--color-brand-bg)] flex items-center justify-center mb-4 sm:mb-5 transition-transform duration-150 group-hover:scale-110" aria-hidden="true">
{icon}
</div>
{/* Badge + Title */}
<div className="flex items-center gap-2 mb-2">
<h3 className="font-sans text-[17px] sm:text-[19px] font-semibold text-[var(--color-text-primary)]">
{title}
</h3>
{badge && (
<span className="text-[10px] tracking-[2px] uppercase px-2 py-0.5 rounded-full bg-[var(--color-brand-bg)] text-brand-ink font-medium">
{badge}
</span>
)}
</div>
{/* Description */}
<p className="text-[13px] sm:text-[14px] text-[var(--color-text-muted)] leading-relaxed mb-4 sm:mb-5">
{description}
</p>
{/* CTA link */}
<span className="inline-flex items-center gap-1.5 text-[13px] font-medium text-[var(--color-text-primary)] transition-all duration-normal group-hover:text-brand-ink group-hover:gap-2.5">
了解更多
<ArrowRight className="w-3.5 h-3.5 transition-transform duration-normal group-hover:translate-x-1" />
</span>
</div>
{/* Hover background lift */}
<div className="absolute inset-0 bg-[var(--color-bg-hover)] opacity-0 transition-opacity duration-150 pointer-events-none" />
<div
className="absolute inset-0 opacity-0 transition-opacity duration-normal pointer-events-none"
onMouseEnter={(e) => { e.currentTarget.style.opacity = '1'; }}
/>
</StaticLink>
);
}
@@ -1,57 +0,0 @@
'use client';
import { motion } from 'framer-motion';
import { ProductCard } from '@/components/ui/product-card';
import { GeometricDecoration } from '@/components/ui/brand-visuals';
import { PRODUCTS } from '@/lib/constants';
import { useReducedMotion } from '@/hooks/use-reduced-motion';
export function ProductMatrixSection() {
const shouldReduceMotion = useReducedMotion();
return (
<section id="products" className="relative py-16 md:py-20 bg-[var(--color-bg-primary)] bg-texture-grid">
<GeometricDecoration variant="lines" />
<div className="container-wide relative z-10">
<motion.div
initial={shouldReduceMotion ? {} : { opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true, margin: '-100px' }}
transition={{ duration: 0.28, ease: [0.16, 1, 0.3, 1] }}
className="flex flex-col md:flex-row md:items-end md:justify-between gap-4 mb-14"
>
<div>
<h2 className="text-3xl sm:text-4xl font-semibold text-[var(--color-text-primary)] mb-3">
产品矩阵
</h2>
<p className="text-base text-[var(--color-text-muted)] max-w-lg">
6 款自研产品覆盖企业数字化全场景,目前全部<span className="text-brand-ink font-medium">研发中</span>,欢迎提前了解规划
</p>
</div>
<div className="flex items-center gap-2">
<span className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-[var(--color-brand-bg)] text-brand-ink text-xs font-medium border border-brand/10">
<span className="w-1.5 h-1.5 rounded-full bg-[var(--color-brand)] animate-pulse" />
研发中 · 即将上线
</span>
<span className="text-sm text-[var(--color-text-subtle)] font-mono tracking-wider hidden md:block">
{PRODUCTS.length} PRODUCTS
</span>
</div>
</motion.div>
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 md:gap-8">
{PRODUCTS.map((product, index) => (
<ProductCard
key={product.id}
title={product.title}
description={product.description}
href={`/products/${product.id}`}
index={index}
status={product.status}
/>
))}
</div>
</div>
</section>
);
}
-58
View File
@@ -1,58 +0,0 @@
'use client';
import { StaticLink } from '@/components/ui/static-link';
import { ChevronRight } from 'lucide-react';
interface QuestionCardProps {
/** The strategic question */
question: string;
/** The answer/description */
description: string;
/** Link href */
href: string;
/** Link text (default "了解详情") */
linkText?: string;
className?: string;
}
export function QuestionCard({
question,
description,
href,
linkText = '了解详情',
className = '',
}: QuestionCardProps) {
return (
<div
className={`group md:grid md:grid-cols-2 border-b border-[var(--color-border-primary)] relative overflow-hidden ${className}`}
>
{/* Left accent bar — visible on hover */}
<div className="absolute left-0 top-0 bottom-0 w-[3px] hidden md:block transition-transform duration-normal origin-top bg-[var(--color-brand)]"
style={{ transform: 'scaleY(0)' }}
onMouseEnter={(e) => { e.currentTarget.style.transform = 'scaleY(1)'; }}
/>
{/* Question — left column */}
<div className="py-6 md:py-12 lg:py-16 md:pr-12 lg:pr-16 flex flex-col justify-center">
<h3 className="font-sans text-[18px] sm:text-[20px] md:text-[clamp(20px,3vw,28px)] font-bold leading-[1.35] tracking-[-0.3px] md:tracking-[-0.5px] text-[var(--color-text-primary)]">
{question}
</h3>
</div>
{/* Answer — right column */}
<div className="pb-6 md:py-12 lg:py-16 md:pl-12 lg:pl-16 md:border-l border-[var(--color-border-primary)] flex flex-col justify-center">
<p className="text-[14px] sm:text-[15px] leading-relaxed mb-5 md:mb-7 text-[var(--color-text-muted)]">
{description}
</p>
<StaticLink
href={href}
className="inline-flex items-center gap-2 text-[13px] font-medium text-[var(--color-text-primary)] transition-all duration-normal hover:text-brand-ink group/link"
style={{ minHeight: '44px', minWidth: '44px' }}
>
{linkText}
<ChevronRight className="w-3.5 h-3.5 transition-transform duration-normal group-hover/link:translate-x-1" />
</StaticLink>
</div>
</div>
);
}
-148
View File
@@ -158,154 +158,6 @@ describe('SectionHeader', () => {
});
});
describe('ProductCard', () => {
it('should render title, description and icon', async () => {
const { ProductCard } = await import('./product-card');
render(
<ProductCard
icon={<span data-testid="custom-icon">★</span>}
title="ERP 系统"
description="企业资源管理系统"
href="/products/erp"
/>
);
expect(screen.getByText('ERP 系统')).toBeInTheDocument();
expect(screen.getByText('企业资源管理系统')).toBeInTheDocument();
expect(screen.getByTestId('custom-icon')).toBeInTheDocument();
expect(screen.getByTestId('static-link')).toHaveAttribute('href', '/products/erp');
});
it('should render badge when provided', async () => {
const { ProductCard } = await import('./product-card');
render(
<ProductCard
icon={<span>★</span>}
title="ERP"
description="Desc"
href="/products/erp"
badge="新版本"
/>
);
expect(screen.getByText('新版本')).toBeInTheDocument();
});
it('should render "了解更多" link', async () => {
const { ProductCard } = await import('./product-card');
render(
<ProductCard
icon={<span>★</span>}
title="ERP"
description="Desc"
href="/products/erp"
/>
);
expect(screen.getByText('了解更多')).toBeInTheDocument();
});
it('should apply custom className', async () => {
const { ProductCard } = await import('./product-card');
render(
<ProductCard
icon={<span>★</span>}
title="ERP"
description="Desc"
href="/products/erp"
className="card-class"
/>
);
const link = screen.getByTestId('static-link');
expect(link.className).toContain('card-class');
});
});
describe('ServiceCard', () => {
it('should render title, description and link', async () => {
const { ServiceCard } = await import('./service-card');
render(
<ServiceCard
title="战略咨询"
description="业务诊断与战略规划"
href="/services/consulting"
/>
);
expect(screen.getByText('战略咨询')).toBeInTheDocument();
expect(screen.getByText('业务诊断与战略规划')).toBeInTheDocument();
expect(screen.getByText('了解详情')).toBeInTheDocument();
expect(screen.getByTestId('next-link')).toHaveAttribute('href', '/services/consulting');
});
it('should apply custom className', async () => {
const { ServiceCard } = await import('./service-card');
render(
<ServiceCard
title="Data"
description="Analysis"
href="/services/data"
className="service-class"
/>
);
const elements = screen.getAllByTestId('motion-div');
const target = elements.find(el => el.className.includes('service-class'));
expect(target).toBeTruthy();
});
it('should accept optional number and color props for compatibility', async () => {
const { ServiceCard } = await import('./service-card');
render(
<ServiceCard
number="03"
title="Blue"
description="Service"
href="/services/test"
color="blue"
/>
);
// ServiceCard has multiple motion.div elements, use getAllByTestId
const elements = screen.getAllByTestId('motion-div');
expect(elements.length).toBeGreaterThan(0);
});
});
describe('CTASection', () => {
it('should render default content', async () => {
const { CTASection } = await import('./cta-section');
render(<CTASection />);
expect(screen.getByText('一起聊聊您的数字化需求')).toBeInTheDocument();
expect(screen.getByText('预约咨询')).toBeInTheDocument();
});
it('should render custom title and description', async () => {
const { CTASection } = await import('./cta-section');
render(
<CTASection
title="Custom Title"
description="Custom description"
primaryLabel="Get Started"
primaryHref="/start"
secondaryLabel="Learn More"
secondaryHref="/about"
/>
);
expect(screen.getByText('Custom Title')).toBeInTheDocument();
expect(screen.getByText('Custom description')).toBeInTheDocument();
expect(screen.getByText('Get Started')).toBeInTheDocument();
expect(screen.getByText('Learn More')).toBeInTheDocument();
});
it('should have proper links', async () => {
const { CTASection } = await import('./cta-section');
render(<CTASection primaryHref="/contact" />);
const links = screen.getAllByTestId('static-link');
expect(links.length).toBeGreaterThan(0);
});
it('should render brand stamp', async () => {
const { CTASection } = await import('./cta-section');
render(<CTASection />);
expect(screen.getByTestId('brand-stamp')).toBeInTheDocument();
});
});
// HeroSectionV2 的三个用例随组件本体一同删除(2026-10-16):
// 该组件全站零生产引用(仅被本测试文件 dynamic import),属 qa-tracker DEC-P-2 死码族。
// 保留测试会让死码继续占用覆盖率分母,并在视觉上被误读为「有活在跑」。
-58
View File
@@ -1,58 +0,0 @@
'use client';
import { ServiceCard, type ServiceColor } from './service-card';
import { SectionHeader } from './section-header';
interface ServiceItem {
number: string;
title: string;
description: string;
color?: ServiceColor;
href: string;
}
interface ServiceGridProps {
label?: string;
title: string;
highlight?: string;
desc?: string;
items: ServiceItem[];
className?: string;
columns?: 2 | 3 | 4;
}
export function ServiceGrid({
label = '我们的服务',
title,
highlight,
desc,
items,
className = '',
columns = 3,
}: ServiceGridProps) {
const gridCols = {
2: 'md:grid-cols-2',
3: 'md:grid-cols-2 lg:grid-cols-3',
4: 'md:grid-cols-2 lg:grid-cols-4',
};
return (
<section className={`section-padding ${className}`}>
<div className="container-x">
<SectionHeader label={label} title={title} highlight={highlight} desc={desc} />
<div className={`grid grid-cols-1 ${gridCols[columns]} gap-6 md:gap-8`}>
{items.map((item, index) => (
<ServiceCard
key={item.title}
title={item.title}
description={item.description}
href={item.href}
delay={index * 0.1}
/>
))}
</div>
</div>
</section>
);
}
@@ -1,120 +0,0 @@
'use client';
import { motion } from 'framer-motion';
import { Shield, Users, Cpu, Handshake, Quote } from 'lucide-react';
import { useReducedMotion } from '@/hooks/use-reduced-motion';
const METRICS = [
{ icon: Users, value: '首批', label: '客户共创', description: '案例与口碑持续积累中' },
{ icon: Cpu, value: '6', label: '自研产品', description: '覆盖企业数字化全场景' },
{ icon: Shield, value: '100%', label: '结果导向', description: '以业务改善为交付承诺' },
{ icon: Handshake, value: '2026', label: '年成立', description: '1 月 15 日于成都启航' },
];
const TESTIMONIALS = [
{
quote: '期待与您一起,把数字化转型从蓝图变为现实。',
author: '睿新致远团队',
role: '首批项目推进中',
},
{
quote: '我们珍视每一位客户的信任,用可衡量的结果赢得口碑。',
author: '睿新致远团队',
role: '客户成功承诺',
},
];
export function SocialProofSection() {
const shouldReduceMotion = useReducedMotion();
return (
<section id="social-proof" role="region" aria-labelledby="social-proof-heading" className="py-16 md:py-24 lg:py-28 relative overflow-hidden">
{/* Background accent */}
<div className="absolute inset-0 bg-[var(--color-bg-primary)]" aria-hidden="true" />
<div className="absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-brand/10 to-transparent" aria-hidden="true" />
<div className="absolute bottom-0 left-0 right-0 h-px bg-gradient-to-r from-transparent via-[var(--color-border-primary)] to-transparent" aria-hidden="true" />
<div className="container-wide relative z-10">
{/* Section Header */}
<motion.div
initial={shouldReduceMotion ? {} : { opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true, margin: '-100px' }}
transition={{ duration: 0.28, ease: [0.16, 1, 0.3, 1] }}
className="text-center max-w-3xl mx-auto mb-16"
>
<h2 id="social-proof-heading" className="text-3xl sm:text-4xl font-semibold text-[var(--color-text-primary)] mb-4">
用数字说话
</h2>
<p className="text-base text-[var(--color-text-muted)]">
我们相信长期主义,用实际成果赢得每一位客户的信任
</p>
</motion.div>
{/* Metrics Bar - horizontal layout instead of card grid */}
<motion.div
initial={shouldReduceMotion ? {} : { opacity: 0, y: 24 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true, margin: '-80px' }}
transition={{ duration: 0.28, ease: [0.16, 1, 0.3, 1] }}
className="grid grid-cols-2 lg:grid-cols-4 gap-6 md:gap-8 mb-16"
>
{METRICS.map((metric, idx) => {
const Icon = metric.icon;
return (
<motion.div
key={metric.label}
initial={shouldReduceMotion ? {} : { opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true, margin: '-60px' }}
transition={{ duration: 0.28, delay: idx * 0.06, ease: [0.16, 1, 0.3, 1] }}
className="text-center group"
>
<div className="w-12 h-12 rounded-full bg-brand/5 flex items-center justify-center mx-auto mb-4 group-hover:bg-brand/10 transition-colors duration-normal">
<Icon className="w-5 h-5 text-brand-ink" strokeWidth={1.5} />
</div>
<div className="text-4xl md:text-5xl font-bold text-[var(--color-text-primary)] tracking-tight mb-1">
{metric.value}
</div>
<div className="text-sm font-medium text-[var(--color-text-secondary)] mb-1">
{metric.label}
</div>
<div className="text-xs text-[var(--color-text-subtle)] max-w-[160px] mx-auto">
{metric.description}
</div>
</motion.div>
);
})}
</motion.div>
{/* Testimonials - quote cards instead of icon cards */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 md:gap-8">
{TESTIMONIALS.map((t, idx) => (
<motion.div
key={idx}
initial={shouldReduceMotion ? {} : { opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true, margin: '-60px' }}
transition={{ duration: 0.28, delay: 0.2 + idx * 0.1, ease: [0.16, 1, 0.3, 1] }}
className="relative p-6 md:p-8 rounded-2xl bg-[var(--color-bg-section)] border border-[var(--color-border-primary)] hover:border-[rgba(var(--color-brand-rgb),0.2)] transition-all duration-normal"
>
<Quote className="w-8 h-8 text-brand-ink/15 mb-4" strokeWidth={1.5} />
<blockquote className="text-[var(--color-text-secondary)] text-base leading-relaxed mb-6">
&ldquo;{t.quote}&rdquo;
</blockquote>
<div className="flex items-center gap-3">
<div className="w-10 h-10 rounded-full bg-gradient-to-br from-brand/10 to-brand/5 flex items-center justify-center">
<span className="text-sm font-semibold text-brand-ink">{t.author[0]}</span>
</div>
<div>
<div className="text-sm font-medium text-[var(--color-text-primary)]">{t.author}</div>
<div className="text-xs text-[var(--color-text-subtle)]">{t.role}</div>
</div>
</div>
</motion.div>
))}
</div>
</div>
</section>
);
}
-185
View File
@@ -1,185 +0,0 @@
'use client';
import { motion } from 'framer-motion';
import { StaticLink } from '@/components/ui/static-link';
import { Button } from '@/components/ui/button';
import { Shield, Building2, Users, Code, Target, ArrowRight } from 'lucide-react';
import { useReducedMotion } from '@/hooks/use-reduced-motion';
const TRUST_PILLARS = [
{
icon: Shield,
title: '行业场景聚焦',
description: '核心团队专注技术咨询与企业数字化,服务经验覆盖金融、制造、零售、政务等多个行业',
stat: '6',
statLabel: '行业场景',
},
{
icon: Building2,
title: '专业工程背景',
description: '开发团队具备扎实的工程能力和规范化交付经验',
stat: '10+',
statLabel: '人核心团队',
},
{
icon: Users,
title: '复合型技术团队',
description: '既懂技术又懂业务,深入理解客户真实场景,提供真正可落地的解决方案',
stat: '6',
statLabel: '款自研产品',
},
{
icon: Code,
title: '全栈技术能力',
description: '从前端到后端、云原生到数据智能、移动端到物联网的全栈技术能力',
stat: '5+',
statLabel: '个覆盖行业',
},
{
icon: Target,
title: '结果导向交付',
description: '不以"项目上线"为终点,以"客户业务是否真正改善"为衡量标准',
stat: '100%',
statLabel: '项目交付率',
},
];
export function WhyUsSection() {
const shouldReduceMotion = useReducedMotion();
return (
<section id="why-us" className="relative py-20 md:py-28 bg-[var(--color-bg-section)] bg-texture-dots overflow-hidden">
{/* Decorative large numbers background */}
<div className="absolute inset-0 overflow-hidden pointer-events-none" aria-hidden="true">
<span className="absolute -top-24 -left-12 text-[20rem] font-bold text-brand-ink/[0.02] leading-none select-none font-calligraphy">睿</span>
<span className="absolute -bottom-32 -right-8 text-[16rem] font-bold text-brand-ink/[0.02] leading-none select-none">新</span>
</div>
<div className="container-wide relative z-10">
<motion.div
initial={shouldReduceMotion ? {} : { opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true, margin: '-100px' }}
transition={{ duration: 0.28, ease: [0.16, 1, 0.3, 1] }}
className="mb-14"
>
<div className="inline-flex items-center gap-2 px-4 py-1.5 rounded-full bg-[var(--color-brand-bg)] border border-brand/10 mb-4">
<span className="w-1.5 h-1.5 rounded-full bg-[var(--color-brand)]" />
<span className="text-xs font-medium tracking-wider text-brand-ink">核心优势</span>
</div>
<h2 className="text-3xl sm:text-4xl font-semibold text-[var(--color-text-primary)] mb-4">
为什么选择<span className="text-brand-ink font-calligraphy">我们</span>
</h2>
<p className="text-base text-[var(--color-text-muted)]">
我们不是一家&ldquo;做完就跑&rdquo;的外包公司,而是愿意与您一起成长的数字化转型同行者
</p>
</motion.div>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 md:gap-8 mb-16">
{TRUST_PILLARS.slice(0, 5).map((pillar, idx) => {
const Icon = pillar.icon;
return (
<motion.div
key={pillar.title}
initial={shouldReduceMotion ? {} : { opacity: 0, y: 24, scale: 0.96 }}
whileInView={{ opacity: 1, y: 0, scale: 1 }}
viewport={{ once: true, margin: '-60px' }}
transition={{ duration: 0.28, delay: idx * 0.06, ease: [0.16, 1, 0.3, 1] }}
className="relative group p-6 md:p-8 rounded-2xl bg-[var(--color-bg-primary)] border border-[var(--color-border-primary)] hover:border-[rgba(var(--color-brand-rgb),0.25)] transition-all duration-normal"
>
<div className="flex items-start justify-between mb-4">
<div
className="w-11 h-11 rounded-xl flex items-center justify-center"
style={{
backgroundColor: idx === 0 ? 'var(--color-brand-bg)' :
idx === 1 ? 'rgba(var(--color-accent-blue-rgb), 0.08)' :
idx === 2 ? 'rgba(var(--color-accent-purple-rgb), 0.08)' :
idx === 3 ? 'rgba(var(--color-accent-cyan-rgb), 0.08)' :
'var(--color-brand-bg)',
}}
>
<Icon
className="w-5 h-5"
style={{
color: idx === 0 ? 'var(--color-brand)' :
idx === 1 ? 'var(--color-accent-blue)' :
idx === 2 ? 'var(--color-accent-purple)' :
idx === 3 ? 'var(--color-accent-cyan)' :
'var(--color-brand)',
}}
strokeWidth={1.8}
/>
</div>
<div className="text-right">
<div
className="text-2xl font-bold leading-none"
style={{
color: idx === 0 ? 'var(--color-brand)' :
idx === 1 ? 'var(--color-accent-blue)' :
idx === 2 ? 'var(--color-accent-purple)' :
idx === 3 ? 'var(--color-accent-cyan)' :
'var(--color-brand)',
}}
>{pillar.stat}</div>
<div className="text-[10px] text-[var(--color-text-subtle)] mt-0.5">{pillar.statLabel}</div>
</div>
</div>
<h3 className="text-base font-semibold text-[var(--color-text-primary)] mb-2">{pillar.title}</h3>
<p className="text-sm text-[var(--color-text-muted)] leading-relaxed">{pillar.description}</p>
</motion.div>
);
})}
</div>
<motion.div
initial={shouldReduceMotion ? {} : { opacity: 0, y: 16 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true, margin: '-80px' }}
transition={{ duration: 0.28, delay: 0.3, ease: [0.16, 1, 0.3, 1] }}
className="text-center"
>
<p className="text-sm text-[var(--color-text-muted)] mb-6">想深入了解我们的团队能力?</p>
<Button variant="outline" asChild className="group">
<StaticLink href="/team">
了解核心团队
<ArrowRight className="w-4 h-4 ml-2 group-hover:translate-x-1 transition-transform" />
</StaticLink>
</Button>
</motion.div>
{/* Tech Stack / Partners Strip */}
<motion.div
initial={shouldReduceMotion ? {} : { opacity: 0, y: 16 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true, margin: '-60px' }}
transition={{ duration: 0.28, delay: 0.4, ease: [0.16, 1, 0.3, 1] }}
className="mt-16 pt-10 border-t border-[var(--color-border-primary)]"
>
<p className="text-xs text-center text-[var(--color-text-subtle)] mb-6 tracking-wide uppercase">技术伙伴 / 技术栈</p>
<div className="flex flex-wrap items-center justify-center gap-x-10 gap-y-6">
{[
{ name: 'Next.js', abbr: 'NEXT' },
{ name: 'React', abbr: 'REACT' },
{ name: 'TypeScript', abbr: 'TS' },
{ name: 'Node.js', abbr: 'NODE' },
{ name: 'Python', abbr: 'PY' },
{ name: 'Cloud Native', abbr: 'K8S' },
{ name: 'AWS / Azure', abbr: 'CLOUD' },
].map((tech) => (
<div
key={tech.name}
className="group flex flex-col items-center gap-1.5"
>
<div className="px-4 py-2 rounded-lg bg-[var(--color-bg-section)] border border-[var(--color-border-primary)] group-hover:border-[rgba(var(--color-brand-rgb),0.2)] group-hover:bg-brand-bg/30 transition-all duration-normal">
<span className="text-sm font-mono font-medium text-[var(--color-text-subtle)] group-hover:text-brand-ink transition-colors duration-normal tracking-wider">
{tech.abbr}
</span>
</div>
<span className="text-[10px] text-[var(--color-text-muted)]">{tech.name}</span>
</div>
))}
</div>
</motion.div>
</div>
</section>
);
}