§12 轮:对标语法批待拍项落地(DEC-N1/N3/N4/N5/N6 + AUTH-VISUAL + GA4 取证) #33
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