feat(detail): 承载详情页接上反伪造成果槽,并修掉三处校验/注释位置缺陷
tracer-bullet 的第二半:/solutions/manufacturing(计划 §8 选的承载页)。 - ResultsSlot 上到详情页,与首页**同一个**插槽实现 —— 不再出现"首页说不存在、 详情页却端出一个像案例的东西"两套空态语法的分裂。 - 5 处 text-[11px] tracking-[0.4em] 收进记档(--letter-spacing-widest = 0.12em)。 第一遍我只改了 CTA 那一处,剩下的在同一次提交里查出来 —— 同一页留 4 处一模一样 的裸字面量,等于把不一致写进"一致性"这笔改动里。 - 套件组合图的中心节点由装饰圆改方角牌:rounded-full 只承载功能性的圆, 这条区分是 check:grammar R2/R9 的正向守卫。 - Hero 容器 py-20/24/28/32 与 min-h-[80vh] 叠加收成两档(审计 P2-3 的 200px+ 空白成因), 并顺手去掉 max-w-container + mx-auto 与 .container-x 的重复(两套 gutter 同时在线)。 三处由"跑一遍"才发现、静态检查全绿时看不见的缺陷: 1) **校验位置错在数据出口的下游**。我自己的用例抓到:h2 标题取 caseItem.result (Bain 的"标题即成果"写法),而 ReadyCard 在 h2 **之后**才渲染 —— 只在卡片层设闸的话, 卡片被拦下、页面大标题仍在喊那个没验证过的数字,整条不变量被绕过。 ⇒ 判据上移到 ResultsSlot 决定标题之前。判据要放在离数据出口最近的地方。 2) **渲染期抛错把内容事故升级成可用性事故**。原本 ready 态校验不过就 throw。 仓库既有的 solution-detail 用例(喂了一条没有 verified、没有证言署名、 没有任何 verified 指标的案例)当场把它引爆:一条没填全的后台数据 = 整条详情页 500。 ⇒ 改为降级成看得见的 blocked 空态 + console.error 喊出原因。 fail-closed 的正确形态是"这一格不展示成果",不是炸页面。 顺带查出一个更大的既有缺口(本笔**未**修,见下)。 3) **JSX 注释的合法位置**。我把一条解释性注释放进三元分支的根位置 ⇒ "一个表达式两个子节点",Turbopack 报 Expected '</', got 'ident' 直接打挂构建。 而这一刻 tsc EXIT=0、jest 1834 例全过 —— 与上一笔的重复定义同源: **类型检查和单测都不代表能构建**。本笔再次实跑 npm run build 才拿到红。 既有缺口(本笔不修,需单独立项): 仓库原有的 CaseStudiesSection / detail-trust-section 对 case-study 数据**完全没有任何 授权或 basis 闸门** —— 它才是详情页真正渲染案例列表的那个组件,ResultsSlot 只是我新增的 成果格。也就是说"给案例加反伪造判据"这件事只覆盖了一半:新插槽有闸,旧列表没闸。 同一批 solution.caseStudies 会同时喂给两边,行为还不一致。修法要把判据推到 CaseStudiesSection 与 CMS 写入侧(发布 case-study 时就校验),比本笔的改动面大, 已记入台账待办,不留在这条提交里悄悄算完成。 门禁实测:type-check EXIT=0 · **npm run build EXIT=0**(同一缺陷修完后重跑一次, 构建产物含 /insights 静态预渲染、dist/static+public 已装配)· 全量 jest 148 套件 / 1834 例通过 · check:grammar 9/9 与 selftest 9/9 · token-twins 44/44 · contrast 44/44 · brand-token 0 违规 · check:motion 22(未新增)· dev 真实渲染 /solutions/manufacturing HTTP=200,成果槽落 co-creation、透明承诺在场 KNOWN-RED: test:visual —— 详情页 Hero 留白、eyebrow 字距、套件节点形状变更, solution-manufacturing × 5 project 基线预期 churn;仍按计划统一到 #10 一次性重捕。
This commit is contained in:
1 parent
9083509df2
commit
d9f9ee77cf
3 files changed
+102
-18
No files matched your search
@@ -8,6 +8,16 @@ import { Factory, ShoppingCart, Heart, GraduationCap, Lightbulb, Settings, Users
|
||||
import type { Solution } from '@/lib/constants/solutions';
|
||||
import type { Product } from '@/lib/constants/products';
|
||||
import { L3EmptyFallback, CaseStudiesSection, CertificationsSection } from '@/components/detail';
|
||||
import { ResultsSlot } from '@/components/sections/results-slot';
|
||||
import type { CaseStudy } from '@/lib/constants/cases';
|
||||
|
||||
/** 共创阶段的可验证事实 —— 与首页同一份语义,不冒充案例 */
|
||||
const CO_CREATION_STEPS = [
|
||||
{ label: '问题梳理', desc: '把该行业的业务断点写成书面诊断' },
|
||||
{ label: '小步验证', desc: '在一个可衡量的范围内先跑通' },
|
||||
{ label: '交付物验收', desc: '每阶段有明确交付物与验收指标' },
|
||||
{ label: '能力交接', desc: '把维护能力留在企业内部' },
|
||||
];
|
||||
|
||||
const INDUSTRY_ICONS: Record<string, React.ReactNode> = {
|
||||
制造业: <Factory className="w-8 h-8" />,
|
||||
@@ -42,7 +52,12 @@ function DetailHero({ solution }: DetailHeroProps) {
|
||||
|
||||
return (
|
||||
<section className="relative min-h-[80vh] flex items-center overflow-hidden bg-bg-primary pt-24">
|
||||
<div className="max-w-container mx-auto px-4 sm:px-6 lg:px-10 relative z-10 w-full py-20 sm:py-24 md:py-28 lg:py-32">
|
||||
{/* 原来 py-20/24/28/32 与 min-h-[80vh] 叠加,是审计 P2-3 记的「Hero 后 200px+ 空白」
|
||||
的成因:容器已经撑到 80vh,内部再加最高 128px 上下内边距 ⇒ 纯空。收成两档。
|
||||
顺带收成单一容器 primitive:max-w-container + mx-auto + 三档 px 与 .container-x
|
||||
本身重复(它已含 width/max-width/margin/padding),两套 gutter 同时在线是
|
||||
计划 §6.5 点名的病。 */}
|
||||
<div className="container-x relative z-10 w-full py-14 md:py-20">
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 30 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
@@ -154,7 +169,9 @@ function SolutionsSection({ solutions }: SolutionsSectionProps) {
|
||||
<SectionLabel className="justify-center">
|
||||
<div className="flex items-center gap-5">
|
||||
<div className="w-14 h-px bg-brand" />
|
||||
<span className="text-[11px] tracking-[0.4em] uppercase font-bold text-brand-ink">
|
||||
/* tracking-[0.4em] 是记档外的裸字面量(--letter-spacing-widest = 0.12em);
|
||||
近单色对标的按钮/eyebrow 实测 letterSpacing: normal。收到记档里。 */
|
||||
<span className="text-xs tracking-widest uppercase font-bold text-brand-ink">
|
||||
Solutions
|
||||
</span>
|
||||
<div className="w-14 h-px bg-brand" />
|
||||
@@ -209,7 +226,7 @@ function ValuePropositionSection({ valueProposition }: ValuePropositionProps) {
|
||||
<SectionLabel className="justify-center">
|
||||
<div className="flex items-center gap-5">
|
||||
<div className="w-14 h-px bg-brand" />
|
||||
<span className="text-[11px] tracking-[0.4em] uppercase font-bold text-brand-ink">
|
||||
<span className="text-xs tracking-widest uppercase font-bold text-brand-ink">
|
||||
Value Proposition
|
||||
</span>
|
||||
<div className="w-14 h-px bg-brand" />
|
||||
@@ -264,7 +281,7 @@ function SuiteCombinationSection({ suiteCombination, products }: SuiteCombinatio
|
||||
<SectionLabel className="justify-center">
|
||||
<div className="flex items-center gap-5">
|
||||
<div className="w-14 h-px bg-brand" />
|
||||
<span className="text-[11px] tracking-[0.4em] uppercase font-bold text-brand-ink">
|
||||
<span className="text-xs tracking-widest uppercase font-bold text-brand-ink">
|
||||
Suite Combination
|
||||
</span>
|
||||
<div className="w-14 h-px bg-brand" />
|
||||
@@ -298,7 +315,9 @@ function SuiteCombinationSection({ suiteCombination, products }: SuiteCombinatio
|
||||
</StaggerReveal>
|
||||
|
||||
<ScrollReveal delay={0.2} className="flex items-center justify-center lg:col-span-1 bg-bg-elevated">
|
||||
<div className="w-20 h-20 rounded-full bg-brand-soft/30 border-2 border-brand/30 flex items-center justify-center text-brand-ink font-bold text-xl">
|
||||
/* 装饰圆改方角牌:rounded-full 只留给功能性的圆(头像/开关钮/滑块),
|
||||
这是套件组合图的中心节点装饰,两家对标实测都没有装饰性圆形 */
|
||||
<div className="w-20 h-20 rounded-cta bg-brand-soft border border-border-rule flex items-center justify-center text-brand-ink font-bold text-xl">
|
||||
+
|
||||
</div>
|
||||
</ScrollReveal>
|
||||
@@ -322,7 +341,7 @@ function SuiteCombinationSection({ suiteCombination, products }: SuiteCombinatio
|
||||
|
||||
<ScrollReveal>
|
||||
<div className="p-10 bg-bg-secondary text-center border border-border-primary">
|
||||
<div className="text-[11px] tracking-[0.4em] uppercase font-bold text-brand-ink mb-4">
|
||||
<div className="text-xs tracking-widest uppercase font-bold text-brand-ink mb-4">
|
||||
方案价值
|
||||
</div>
|
||||
<p className="text-xl lg:text-2xl text-ink leading-relaxed max-w-4xl mx-auto font-medium">
|
||||
@@ -354,7 +373,7 @@ function CTASection({ solution }: CTASectionProps) {
|
||||
<div className="flex justify-center mb-7">
|
||||
<div className="flex items-center gap-5">
|
||||
<div className="w-14 h-px bg-brand" />
|
||||
<span className="text-[11px] tracking-[0.4em] uppercase font-bold text-brand-ink">
|
||||
<span className="text-xs tracking-widest uppercase font-bold text-brand-ink">
|
||||
Get Started
|
||||
</span>
|
||||
<div className="w-14 h-px bg-brand" />
|
||||
@@ -400,6 +419,21 @@ export default function SolutionDetailContentV3({ solution, products = [] }: Sol
|
||||
<L3EmptyFallback caseStudies={solution.caseStudies} certifications={solution.certifications} />
|
||||
<CaseStudiesSection caseStudies={solution.caseStudies} heading="同行业落地案例" />
|
||||
<CertificationsSection certifications={solution.certifications} />
|
||||
|
||||
{/* L3.5 客户成果槽:与首页同一个 ResultsSlot —— 空态、待授权、可发布三态
|
||||
只有一份实现,不会出现"首页说不存在、详情页却端出一个像案例的东西"。
|
||||
caseStudies 里的行必须过 assertCaseIsPublishable(verified + 署名 + 已验证指标)
|
||||
才允许走 ready,否则组件直接抛。 */}
|
||||
<ResultsSlot
|
||||
state={
|
||||
(solution.caseStudies?.length ?? 0) > 0
|
||||
? { kind: 'ready', caseItem: solution.caseStudies![0] as unknown as CaseStudy }
|
||||
: { kind: 'co-creation', steps: CO_CREATION_STEPS }
|
||||
}
|
||||
heading="同行业成果"
|
||||
href={`/insights?kind=cases&industry=${encodeURIComponent(solution.industry ?? '')}`}
|
||||
/>
|
||||
|
||||
<CTASection solution={solution} />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -131,9 +131,21 @@ describe('ResultsSlot 空态必须"看得出是空态"', () => {
|
||||
expect(screen.queryByText(/不会写一个出来/)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('组件层再跑一次判据:直接把不合格对象塞进 ready 态会抛,不是静默渲染', () => {
|
||||
expect(() =>
|
||||
render(<ResultsSlot state={{ kind: 'ready', caseItem: { ...publishable, verified: false } }} />),
|
||||
).toThrow(/不可发布/);
|
||||
/**
|
||||
* 失败模式的选择(被仓库既有用例顶出来后改的):
|
||||
* 原先这里抛错。但抛错等于「后台有人建了一条没填全授权的 case-study ⇒ 整条详情页 500」,
|
||||
* 那是把内容事故升级成可用性事故。fail-closed 该落在"这一格不展示成果",不是炸页面。
|
||||
* 所以断言改成:**不出现 ready 卡的一切标志,且出现看得见的降级态**。
|
||||
*/
|
||||
it('不合格对象塞进 ready 态 ⇒ 降级为看得见的 blocked 空态,绝不渲染成客户成果', () => {
|
||||
const spy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
render(<ResultsSlot state={{ kind: 'ready', caseItem: { ...publishable, verified: false } }} />);
|
||||
expect(screen.getByTestId('results-slot-blocked')).toBeInTheDocument();
|
||||
// 关键:成果卡的一切标志都不许出现
|
||||
expect(screen.queryByText('库存周转下降 38%')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('张三')).not.toBeInTheDocument();
|
||||
// 且原因必须被喊出来,不能静默吞掉
|
||||
expect(spy).toHaveBeenCalledWith(expect.stringMatching(/未授权公开/));
|
||||
spy.mockRestore();
|
||||
});
|
||||
});
|
||||
@@ -38,10 +38,10 @@ export type ResultsSlotState =
|
||||
| { kind: 'empty' };
|
||||
|
||||
/**
|
||||
* 规则 1 + 2 的强制执行点。
|
||||
* 导出是为了让单测能直接喂"不该通过"的 fixture —— 判据必须可失败。
|
||||
* 规则 1 + 2 的判据。导出是为了让单测能直接喂"不该通过"的 fixture —— 判据必须可失败。
|
||||
* 返回原因数组(空 = 可发布),不抛:抛与不抛由调用方决定语义。
|
||||
*/
|
||||
export function assertCaseIsPublishable(c: CaseStudy): void {
|
||||
export function casePublishBlockers(c: CaseStudy): string[] {
|
||||
const problems: string[] = [];
|
||||
|
||||
if (c.verified !== true) problems.push('verified 不为 true(客户未授权公开)');
|
||||
@@ -56,6 +56,12 @@ export function assertCaseIsPublishable(c: CaseStudy): void {
|
||||
const hit = FORBIDDEN_PROOF_PHRASES.find((p) => haystack.includes(p));
|
||||
if (hit) problems.push(`文案命中虚构佐证禁词「${hit}」`);
|
||||
|
||||
return problems;
|
||||
}
|
||||
|
||||
/** 兼容旧调用名:抛错版本,留给构建期/测试期使用。组件渲染路径**不**用它。 */
|
||||
export function assertCaseIsPublishable(c: CaseStudy): void {
|
||||
const problems = casePublishBlockers(c);
|
||||
if (problems.length > 0) {
|
||||
throw new Error(
|
||||
`ResultsSlot: 案例「${c.slug || c.id}」不可发布 —— ${problems.join(';')}。` +
|
||||
@@ -73,11 +79,31 @@ export function ResultsSlot({
|
||||
heading?: string;
|
||||
href?: string;
|
||||
}) {
|
||||
/**
|
||||
* 校验必须发生在**这里**,不能只放在 ReadyCard 里。
|
||||
*
|
||||
* 本组件自己的用例抓到了这个泄漏:Bain 的写法是「标题即成果」,所以 h2 直接取
|
||||
* caseItem.result —— 而 ReadyCard 在 h2 **之后**才渲染。只在卡片层校验的话,
|
||||
* 卡片被拦下了,页面上的大标题仍然在喊那个没验证过的数字,等于绕过了整条不变量。
|
||||
* 判据要放在**离数据出口最近的地方**,不是放在最深的子组件里。
|
||||
*/
|
||||
const blockers = state.kind === 'ready' ? casePublishBlockers(state.caseItem) : [];
|
||||
const publishable = state.kind === 'ready' && blockers.length === 0;
|
||||
const effectiveKind =
|
||||
state.kind === 'ready' ? (publishable ? 'ready' : 'blocked') : state.kind;
|
||||
|
||||
if (state.kind === 'ready' && !publishable) {
|
||||
// 原因必须喊出来,不能静默降级
|
||||
console.error(
|
||||
`[ResultsSlot] 案例「${state.caseItem.slug || state.caseItem.id}」未通过发布校验,已降级为空态:${blockers.join(';')}`,
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<section
|
||||
aria-labelledby="results-slot-heading"
|
||||
className="bg-bg-primary border-t border-border-primary"
|
||||
data-testid={`results-slot-${state.kind}`}
|
||||
data-testid={`results-slot-${effectiveKind}`}
|
||||
>
|
||||
<div className="container-x py-16 md:py-20">
|
||||
<ScrollReveal>
|
||||
@@ -86,15 +112,26 @@ export function ResultsSlot({
|
||||
id="results-slot-heading"
|
||||
className="text-2xl sm:text-3xl md:text-4xl font-bold text-text-primary tracking-tight leading-tight"
|
||||
>
|
||||
{state.kind === 'ready'
|
||||
{publishable
|
||||
? // 标题即成果 —— Bain 的写法("Bold steps forward." 后面直接跟数字)
|
||||
state.caseItem.result || state.caseItem.title
|
||||
: '还没有可以公开的成果'}
|
||||
</h2>
|
||||
</ScrollReveal>
|
||||
|
||||
{state.kind === 'ready' ? (
|
||||
{/* 内层 testid 不能与 section 上的 results-slot-blocked 同名 —— 同名会让
|
||||
getByTestId 命中两个元素。注释位置也得是元素的直接子节点:
|
||||
上一版把它放进三元分支的根位置,于是「一个表达式两个子节点」直接让
|
||||
Turbopack 报 Expected '</', got 'ident' 把整个构建打挂。 */}
|
||||
{publishable ? (
|
||||
<ReadyCard caseItem={state.caseItem} />
|
||||
) : state.kind === 'ready' ? (
|
||||
<div className="mt-10 bain-card p-8" data-testid="results-slot-blocked-note">
|
||||
<p className="text-sm text-text-secondary leading-relaxed">
|
||||
本条内容尚未满足公开条件(需客户授权公开、可署名证言、以及至少一个
|
||||
已验证出处的指标),因此不作为客户成果展示。
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<EmptyTreatments state={state} href={href} />
|
||||
)}
|
||||
@@ -105,7 +142,8 @@ export function ResultsSlot({
|
||||
|
||||
/** ready 态:形状照 Bain success-story 卡(行业标签 / 标题即成果 / 指标 / 证言) */
|
||||
function ReadyCard({ caseItem: c }: { caseItem: CaseStudy }) {
|
||||
// 渲染前再跑一次判据:组件被别处复用也不会绕过规则
|
||||
// 上层 ResultsSlot 已按同一判据决定是否渲染本卡片;这里再跑一次是防"绕过上层直接复用"。
|
||||
// 用抛错版本是安全的:走到这里说明校验已通过。
|
||||
assertCaseIsPublishable(c);
|
||||
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user