Files
novalon-website/src/app/(marketing)/home-content-v16.tsx
T
zhangxiang 1e80167b7c fix(a11y,e2e): 修 §14 定性出的 6 类功能 E2E 红,含一条 fail-open 与一处我自己造成的重复键
产品侧(真缺陷):
- detail-trust-section 渲染绕过门槛(publishableCases 算了却仍 map caseStudies)⇒
  只要一条过闸,未授权/无 verified 的案例照样上线。改回 publishableCases.map,
  新增 detail-trust-gate.test.tsx 3 例;变异验证:回退成 caseStudies.map ⇒ 2 条精确转红。
- 4 个文字链接触摸目标 23px < WCAG 2.5.8 的 24px(home 全部洞察/了解这一能力、
  成果槽两条 CTA)⇒ 走间距刻度 min-h-6 补齐,不塞任意值。判据本身复跑通过。
- 首页能力面板 role=region 缺可访问名(landmark 无名;axe 的 landmark-name 属
  best-practice 标签,我们的闸只跑 A/AA 所以没报)⇒ 补 aria-label。
- 登录限流额度改为可按环境覆盖(默认仍 10 次/15 分钟/IP,生产姿态不变);
  真因:进程内内存桶 + dev server 跨整轮存活 ⇒ @admin 旅程第 11 次登录起必得 429,
  即 §14 里「单跑绿、全量红」的机理。route.test.ts 加双向用例(未设=10;设 3 ⇒ 第 4 次限流)。

测试侧(锚点/引擎):
- mobile.spec:45、website-acceptance:139 的重锚:锚点取自真源 navigation.ts
  (一级只剩 行业/能力/洞察/关于我们,联系入口是 consult-button 而非导航项)。
- p4:403 焦点管理:webkit/chromium-mobile 上 Tab 不落到链接(Safari 系需系统级
  「Press Tab to highlight each item」,Playwright 起的 webkit 不带),
  我先试 bringToFront + 点空白**没有用**,故改为同契约按引擎取证(chromium 走真实键盘
  Tab,其余显式 focus 跳转链接),断言一条不减;复跑 webkit+mobile 2 passed。
- playwright.config.ts:我把 env 插成了重复键(TS1117),由本批新加的 type-check:e2e 当场抓到
  ——这条闸的价值的又一次现场证明。已合并进既有 env 对象。

待办:全量功能 E2E 终跑(4 project)正在后台,读数与 PR 勾选项的复位随下一笔。
2026-10-17 10:41:57 +08:00

479 lines
23 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use client';
/**
* 首页 v16 —— 对标实测驱动的段序重构(10 段 → 8 段)。
*
* 两家对标的首页段序(我自己量的,非二手描述):
* Bain :洞察报告轮播 hero → 品牌宣言 → 「Bold steps forward.」客户成果(标题即数字)
* → SEE ALL CLIENT RESULTS → 视频 → Our Latest Insights(带分页器)
* → What can we help you achieve? → 招聘带
* Porsche:video hero → In Focus: News & Trends → Our Industry Expertise(行业网格)
* → What Moves Our Clients(4 实践 accordion)→ Empowering Our Clients(8 个案例)
* → Spotlight on AI → 招聘带 → Ready for Change?
* 收敛律:**以编辑内容或客户成果开场;行业成网格;能力做成 accordion;
* 成果单独成一个频道;CTA 收尾且安静。**
*
* 我们填不了其中两格(0 条案例、2 条新闻、无视频、无招聘页),所以诚实的推导是
* **取其顺序、换其内容、并在区块标题里说明换的是什么**(决策 3 零编造透明路线)。
*
* 段序变化与理由:
* 1 Hero —— 保留但重设:删 HeroParticleField(两家实测都没有持续背景运动,
* 且 CONTEXT.md:81 明令禁止循环动画);min-h 90vh→70vh(我们是宣言不是影片)
* 2 数字账本 —— HeroStatsBand + TrustSection **合并**:两段都在说"这是我们的数字",
* 那是冗余不是节奏。合并后数字语法改为 text-5xl/字重500/纯黑
* (Bain 实测;ADR-0004 决策四「超大字号+品牌色」已被证伪)
* 3 透明承诺 —— 提升既有的 L3SignalsSlot,而非新造组件
* 4 客户成果槽 —— ResultsSlot 取代 CasesSection:留形状、写清状态
* 5 洞察 —— InsightsSection + NewsSection **合并**(两条本就同轴,
* 且各自都指向 /news = 组件层的竞争真源)
* 6 行业网格 —— 新增,读 solution 模型 6 行(Porsche 的 Our Industry Expertise)
* 7 能力 accordion —— ServicesSection 转换(恰好 4 条 service ⇒ 恰好 4 个实践组)
* 8 CTA —— 保留
* ✕ NarrativeSection 删除:01/02/03 诊断→设计→交付与 /methodology 重复,
* 其 text-4xl/5xl font-black 装饰编号正是「装饰大字对比度裁决」要防的那个手法
* ✕ FounderQuoteSection 删除:它是全站唯一 bg-brand-section #8B1530 满幅面,
* 而实测两家都是「饱和红只做点缀、绝不做页面背景」;CEO 引言带是 Accenture 语法,
* 两家都没有。两行 pull-quote 降为第 3 段的正文
*/
import { useState } from 'react';
import { ScrollReveal, StaggerReveal } from '@/components/ui/scroll-reveal';
import { StaticLink } from '@/components/ui/static-link';
import { CTAButton } from '@/components/ui/cta-button';
import { SectionLabel } from '@/components/ui/page-decoration';
import { MetricsBasisNote } from '@/components/ui/metrics-basis-note';
import { L3SignalsSlot } from '@/components/detail/l3-signals-slot';
import { ResultsSlot, type CoCreationStep, type ResultsSlotState } from '@/components/sections/results-slot';
import type { CaseStudy } from '@/lib/constants/cases';
import { weakestBasis } from '@/lib/constants/metrics-basis';
import { INQUIRY_RESPONSE_COMMITMENT, FREE_FIRST_CONSULT } from '@/lib/constants/commitments';
import { canonicalCtaLabel, CTA_LABELS } from '@/lib/constants/cta-labels';
import { COMPANY_INFO } from '@/lib/constants';
import { cn } from '@/lib/utils';
import { Factory, ShoppingBag, GraduationCap, HeartPulse, Landmark, Truck, ArrowRight } from 'lucide-react';
import type { NewsItem } from '@/lib/constants/news';
type Row = Record<string, unknown>;
/** 行业网格:6 条 solution 行的 industry + 图标。纯读取,不新增数据源 */
const INDUSTRY_TILES = [
{ slug: 'manufacturing', name: '制造业', icon: Factory },
{ slug: 'retail', name: '贸易零售', icon: ShoppingBag },
{ slug: 'education', name: '教育培训', icon: GraduationCap },
{ slug: 'healthcare', name: '医疗健康', icon: HeartPulse },
{ slug: 'finance', name: '金融服务', icon: Landmark },
{ slug: 'logistics', name: '物流运输', icon: Truck },
] as const;
/** 共创阶段的可验证事实 —— 不是案例,也不冒充案例 */
const CO_CREATION_STEPS: CoCreationStep[] = [
{ label: '问题梳理', desc: '把业务断点写清楚,形成书面诊断' },
{ label: '小步验证', desc: '在一个可衡量的范围内先跑通' },
{ label: '交付物验收', desc: '每阶段有明确交付物与验收指标' },
{ label: '能力交接', desc: '把维护能力留在企业内部' },
];
/* ───────────────────────── 1. Hero ───────────────────────── */
function HomeHero({ heroData }: { heroData?: Row | null }) {
const heading = (heroData?.heading as string) || (heroData?.headingBottom as string)
|| '让每一家企业都拥有数据驱动的决策能力';
const subheading = (heroData?.subheading as string) || (heroData?.description as string) || '';
const ctaLabel = canonicalCtaLabel(heroData?.ctaLabel as string | undefined) || CTA_LABELS.consult;
const ctaHref = (heroData?.ctaHref as string) || '/contact';
const secondaryLabel = (heroData?.secondaryCtaLabel as string) || '看行业实践';
const secondaryHref = (heroData?.secondaryCtaHref as string) || '/solutions';
return (
<section
className="bg-bg-primary border-b border-border-primary"
data-testid="hero-section"
>
{/* min-h 90vh → 70vh:对标两家的 hero 高 722–785px 是**图文影片**,
我们是一句宣言,用满屏高度撑一句宣言只会读成空 */}
<div className="container-x min-h-[70vh] flex items-center py-20">
<div className="max-w-4xl">
{/* 朱砂条(1× 档)作唯一装饰 —— 无渐变、无圆角、无描边 */}
<span className="block w-10 h-[3px] bg-brand mb-7" aria-hidden="true" />
<h1 className="text-4xl sm:text-5xl md:text-6xl font-bold text-text-primary leading-tight tracking-tight">
{heading}
</h1>
{subheading && (
<p className="mt-6 text-base md:text-lg text-text-secondary leading-relaxed max-w-2xl">
{subheading}
</p>
)}
<div className="mt-10 flex flex-wrap items-center gap-4">
<CTAButton href={ctaHref} dataTestId="hero-cta">{ctaLabel}</CTAButton>
<CTAButton href={secondaryHref} variant="secondary">{secondaryLabel}</CTAButton>
</div>
{/* 承诺句走单一真源,不在此硬写数字 */}
<p className="mt-8 text-sm text-text-muted">
{INQUIRY_RESPONSE_COMMITMENT.text} · {FREE_FIRST_CONSULT.text}
</p>
</div>
</div>
</section>
);
}
/* ───────────────── 2. 可审计数字账本 ───────────────── */
interface LedgerEntry { value: string; label: string; basis?: string | null }
function toLedger(stats?: Row[], trust?: Row[]): LedgerEntry[] {
const fromStats = (stats ?? []).map((s) => ({
value: String(s.value ?? ''),
label: String(s.label ?? ''),
basis: (s.basis as string) ?? null,
}));
const fromTrust = (trust ?? []).map((t) => ({
value: String(t.value ?? ''),
label: String(t.label ?? ''),
basis: (t.basis as string) ?? null,
}));
// 两段合并后可能出现同 label 的条目 —— 合并的意义就在于此,去重防它变成"两个真源"
const seen = new Set<string>();
return [...fromStats, ...fromTrust].filter((e) => {
if (!e.value || !e.label || seen.has(e.label)) return false;
seen.add(e.label);
return true;
});
}
/**
* 是否**定量**条目 —— 浏览器实测逼出来的这条判据。
*
* 我原以为 HeroStatsBand 与 TrustSection「都在说同一件事」,所以整段合并、统一按
* Bain 的成果数字语法(--font-size-5xl = 63px / 字重 500 / 纯黑)渲染。真跑起来才发现
* TRUST_SIGNALS 的四条里有 成都 / 全流程 / 共创 这种**根本不是数字**的东西,
* 于是全页最响的一行装着三个名词 —— 恰好是对标(和 ADR-0004 想避免的「数据大字报」)
* 反对的那件事。合并的目标是"一段而不是两段",不是"把定性信号冒充成指标"。
*
* 判据:含数字,或带 % / × / 倍 / 天 / 小时 / 年 等量纲。
*/
const QUANTITIVE = /(\d|%|%|×|倍|天|小时|分钟|年|季度|个月)/;
function isQuantitative(value: string): boolean {
return QUANTITIVE.test(value);
}
function NumberLedger({ stats, trustSignals }: { stats?: Row[]; trustSignals?: Row[] }) {
const all = toLedger(stats, trustSignals);
if (all.length === 0) return null;
const metrics = all.filter((e) => isQuantitative(e.value));
const signals = all.filter((e) => !isQuantitative(e.value));
const weakest = weakestBasis(all.map((e) => e.basis));
return (
<section className="bg-bg-secondary border-b border-border-primary" data-testid="home-ledger">
<div className="container-x py-14 md:py-16">
{metrics.length > 0 && (
/* testid 挂在外层普通 div 上,不挂在 StaggerReveal 上:
真实的 StaggerReveal/ScrollReveal 解构固定 prop 列表、**不透传未知属性**,
所以 data-* 会被静默丢弃(本轮浏览器实测抓到,而 jsdom 单测因 mock 透传了
props 而全绿 —— 典型的「mock 比实现宽松」)。
grid 类仍留在 StaggerReveal 上:QA Q-5 记过「grid 放外层容器会让卡片堆成单列」,
这里外层只是打标,不参与布局。props 透传本身留给组件清理那一批统一做。 */
<div data-testid="home-ledger-metrics">
<StaggerReveal className="grid grid-cols-2 lg:grid-cols-4 gap-x-8 gap-y-10">
{metrics.map((e) => (
<div key={e.label} data-testid="ledger-metric">
{/* 实测对标:Bain 的 500+ / $300M / 2.5x 是 40px / 字重 500 / 纯黑。
--font-size-5xl = 2.25rem,桌面根字号 18px 下正好 40.5px ⇒ 零新增 token。
原 v15 的 font-black + text-brand-ink 是把 ADR-0004 决策四的误读实现了出来。 */}
<div className="text-5xl font-medium tabular-nums text-text-primary leading-none">
{e.value}
</div>
<div className="mt-3 text-sm text-text-muted">{e.label}</div>
</div>
))}
</StaggerReveal>
</div>
)}
{/* 定性信号:留在同一段内(合并的意义),但视觉重量降到配角 ——
小字 + 分隔点,不与上面的数字争同一种强调 */}
{signals.length > 0 && (
<ul
className={cn(
'list-none p-0 m-0 flex flex-wrap gap-x-8 gap-y-2',
metrics.length > 0 ? 'mt-10 pt-8 border-t border-border-primary' : 'mt-0',
)}
data-testid="home-ledger-signals"
>
{signals.map((e) => (
<li key={e.label} className="text-sm text-text-secondary">
<span className="font-medium text-text-primary">{e.value}</span>
<span className="mx-2 text-text-muted" aria-hidden="true">·</span>
{e.label}
</li>
))}
</ul>
)}
<MetricsBasisNote basis={weakest} className="mt-10" />
</div>
</section>
);
}
/* ───────────────── 5. 洞察(原 Insights + News 合并)───────────────── */
function InsightsBlock({ news, pageCopy }: { news?: NewsItem[]; pageCopy?: Record<string, unknown> | null }) {
const items = (news ?? []).slice(0, 4);
const eyebrow = '洞察';
const heading = (pageCopy?.insightsTitle as string) || '我们怎么判断、怎么交付';
return (
<section className="bg-bg-primary border-t border-border-primary" data-testid="home-insights">
<div className="container-x py-16 md:py-24">
<ScrollReveal>
<SectionLabel>{eyebrow}</SectionLabel>
<div className="flex flex-wrap items-end justify-between gap-4 mt-4">
<h2 className="text-2xl sm:text-3xl md:text-4xl font-bold text-text-primary tracking-tight leading-tight max-w-3xl">
{heading}
</h2>
<StaticLink
href="/insights"
className="min-h-6 inline-flex items-center gap-1 text-sm font-medium text-text-primary hover:text-brand-ink transition-colors duration-hover"
>
全部洞察
<ArrowRight className="w-4 h-4" aria-hidden="true" />
</StaticLink>
</div>
</ScrollReveal>
{items.length === 0 ? (
<div className="bain-card p-8 mt-10" data-testid="home-insights-empty">
<p className="text-sm text-text-secondary leading-relaxed">
公开写作还在积累。可以先看{' '}
<StaticLink href="/methodology" className="text-brand-ink hover:text-brand-ink-hover underline underline-offset-4">
方法论
</StaticLink>
,它说明我们怎么工作。
</p>
</div>
) : (
<StaggerReveal className="grid gap-4 md:grid-cols-2 mt-10">
{items.map((n) => (
<StaticLink
key={n.id}
href={`/news/${n.id}`}
className="bain-card block p-7 transition-colors duration-hover hover:border-border-rule"
>
<div className="flex items-center gap-3 text-xs text-text-muted mb-3">
<span className="text-brand-ink font-medium">{n.category}</span>
<span className="tabular-nums">{n.date}</span>
</div>
<h3 className="text-lg font-semibold text-text-primary leading-snug">{n.title}</h3>
<p className="mt-2 text-sm text-text-secondary leading-relaxed">{n.excerpt}</p>
</StaticLink>
))}
</StaggerReveal>
)}
</div>
</section>
);
}
/* ───────────────── 6. 行业网格 ───────────────── */
function IndustryGridBlock({ solutions }: { solutions?: Row[] }) {
const bySlug = new Map((solutions ?? []).map((s) => [String(s.id ?? s.slug ?? ''), s]));
return (
<section className="bg-bg-secondary border-t border-border-primary" data-testid="home-industries">
<div className="container-x py-16 md:py-24">
<ScrollReveal>
<SectionLabel>行业</SectionLabel>
<h2 className="text-2xl sm:text-3xl md:text-4xl font-bold text-text-primary tracking-tight leading-tight mt-4 max-w-3xl">
按行业的问题空间,不是按我们的产品线
</h2>
</ScrollReveal>
<StaggerReveal className="grid grid-cols-2 md:grid-cols-3 gap-px mt-10 bg-border-primary">
{INDUSTRY_TILES.map((tile) => {
const Icon = tile.icon;
const row = bySlug.get(tile.slug);
const painPoints = Array.isArray(row?.painPoints) ? (row!.painPoints as unknown[]).slice(0, 2) : [];
return (
<StaticLink
key={tile.slug}
href={`/solutions/${tile.slug}`}
className="bg-bg-primary p-6 transition-colors duration-hover hover:bg-bg-tertiary"
>
<Icon className="w-5 h-5 text-brand-ink" aria-hidden="true" />
<div className="mt-4 text-base font-semibold text-text-primary">{tile.name}</div>
{painPoints.length > 0 && (
<ul className="mt-2 space-y-1 list-none p-0 m-0">
{painPoints.map((p, i) => (
<li key={i} className="text-xs text-text-muted leading-relaxed">
{String(p)}
</li>
))}
</ul>
)}
</StaticLink>
);
})}
</StaggerReveal>
</div>
</section>
);
}
/* ───────────────── 7. 能力 accordion ───────────────── */
interface CapabilityRow { id?: string; name?: string; title?: string; description?: string; highlights?: unknown[] }
function CapabilitiesAccordion({ services }: { services?: CapabilityRow[] }) {
const rows = services ?? [];
const [openId, setOpenId] = useState<string | null>(rows[0]?.id ?? null);
if (rows.length === 0) return null;
return (
<section className="bg-bg-primary border-t border-border-primary" data-testid="home-capabilities">
<div className="container-x py-16 md:py-24">
<ScrollReveal>
<SectionLabel>能力</SectionLabel>
<h2 className="text-2xl sm:text-3xl md:text-4xl font-bold text-text-primary tracking-tight leading-tight mt-4 max-w-3xl">
四种陪跑方式
</h2>
<p className="mt-4 text-base text-text-secondary leading-relaxed max-w-2xl">
对标 Porsche Consulting 的「What Moves Our Clients」:能力用 accordion 承载,
而不是四张等宽卡片 —— 卡片把四件事压成同一视觉重量,accordion 允许逐个展开。
</p>
</ScrollReveal>
<div className="mt-10 border-t border-border-primary">
{rows.map((s, i) => {
const id = String(s.id ?? i);
const open = openId === id;
const title = String(s.title ?? s.name ?? '');
const highlights = Array.isArray(s.highlights) ? (s.highlights as unknown[]).map(String) : [];
return (
<div key={id} className="border-b border-border-primary">
<button
type="button"
onClick={() => setOpenId(open ? null : id)}
aria-expanded={open}
aria-controls={`cap-panel-${id}`}
className="w-full flex items-center justify-between gap-6 py-6 text-left transition-colors duration-hover hover:text-brand-ink min-h-[64px]"
>
<span className="flex items-baseline gap-5">
<span className="text-sm font-medium tabular-nums text-text-muted" aria-hidden="true">
{String(i + 1).padStart(2, '0')}
</span>
<span className="text-lg md:text-xl font-semibold text-text-primary">{title}</span>
</span>
<span className={cn('text-2xl leading-none text-text-muted transition-transform duration-hover', open && 'rotate-45')} aria-hidden="true">
+
</span>
</button>
{open && (
<div id={`cap-panel-${id}`} role="region" aria-label={`${title} 能力详情`} className="pb-8 pl-[3.25rem] pr-2">
<p className="text-sm text-text-secondary leading-relaxed max-w-2xl">
{String(s.description ?? '')}
</p>
{highlights.length > 0 && (
<ul className="mt-5 flex flex-wrap gap-x-6 gap-y-2 list-none p-0 m-0">
{highlights.map((h) => (
<li key={h} className="text-sm text-text-secondary">{h}</li>
))}
</ul>
)}
<StaticLink
href={`/services/${id}`}
className="mt-6 min-h-6 inline-flex items-center gap-1 text-sm font-medium text-brand-ink hover:text-brand-ink-hover transition-colors duration-hover"
>
了解这一能力
<ArrowRight className="w-4 h-4" aria-hidden="true" />
</StaticLink>
</div>
)}
</div>
);
})}
</div>
</div>
</section>
);
}
/* ───────────────── 8. CTA ───────────────── */
function HomeCta({ heroData }: { heroData?: Row | null }) {
const ctaHref = (heroData?.ctaHref as string) || '/contact';
return (
<section className="bg-bg-secondary border-t border-border-primary" data-testid="home-cta">
<div className="container-x py-20 md:py-28 text-center">
<ScrollReveal>
<h2 className="text-2xl sm:text-3xl md:text-4xl font-bold text-text-primary tracking-tight leading-tight">
现在有什么卡住你了?
</h2>
<p className="mt-4 text-base text-text-secondary max-w-2xl mx-auto leading-relaxed">
{COMPANY_INFO.displayName}的定位是伙伴而非供应商 —— 把问题带来,我们先给判断。
</p>
<div className="mt-9 flex flex-wrap items-center justify-center gap-4">
<CTAButton href={ctaHref} dataTestId="home-cta-button">{CTA_LABELS.consult}</CTAButton>
<CTAButton href="/methodology" variant="secondary">看方法论</CTAButton>
</div>
</ScrollReveal>
</div>
</section>
);
}
/* ───────────────── 装配 ───────────────── */
export default function HomeContentV16({
services,
solutions,
cases,
stats,
heroData,
news,
pageCopy,
trustSignals,
}: {
services?: CapabilityRow[];
solutions?: Row[];
cases?: Row[];
stats?: Row[];
heroData?: Row | null;
news?: NewsItem[];
pageCopy?: Record<string, unknown> | null;
trustSignals?: Row[];
}) {
const caseRows = cases ?? [];
// 判别式联合要靠显式类型标注收窄 —— 三元直接推会退化成 { kind: string },
// 那样连编译期都保证不了「ready 一定带 caseItem」
const resultsState: ResultsSlotState =
caseRows.length > 0
? { kind: 'ready', caseItem: caseRows[0] as unknown as CaseStudy }
: { kind: 'co-creation', steps: CO_CREATION_STEPS };
return (
<div>
<HomeHero heroData={heroData} />
<NumberLedger stats={stats} trustSignals={trustSignals} />
{/* 3 透明承诺 + 4 客户成果槽:两段合读才成立 —— 先说"我们用什么建立信任",
再明说"成果这一格现在是空的、为什么空" */}
<L3SignalsSlot
heading="在数据之外,我们用透明度建立信任"
description="客户案例与资质认证需获得授权后才能公开;在那之前,以下四个锚点是我们可验证的承诺。"
/>
<ResultsSlot state={resultsState} />
<InsightsBlock news={news} pageCopy={pageCopy} />
<IndustryGridBlock solutions={solutions} />
<CapabilitiesAccordion services={services} />
<HomeCta heroData={heroData} />
</div>
);
}