feat(ui): 保时捷语法复刻收尾(ADR-0008/0009/0011/0012/0013) #65

Merged
zhangxiang merged 63 commits from feat/porsche-ui-replica into dev 2026-12-02 19:34:32 +08:00
18 changed files with 235 additions and 441 deletions
Showing only changes of commit b31b428e88 - Show all commits

No files matched your search

@@ -67,3 +67,40 @@ E2E_TARGET=production ... --update-snapshots=none → 125 passed / 0 failed
⚠ 纪律:这一条**不得**被用来解释真正的像素回归。判据是「失败集是否可复现」——
同一基线连跑两轮失败集不同 = 抖动;同一张连跑两轮都红 = 真回归。
---
## 2026-11-03 · P5(退役遗留 hero)之后
### 5 张 `/news` 红不是回归,是**构建产物被测试数据污染**
只读复跑时 `/news` 在 5 个 project 上一致判红(不是随机子集,所以先当成真回归查)。
差异区放大后看到多出一张卡片:`E2E 测试新闻 1793691768735-7hak7w`。
链路:E2E 套件里有用例会**写库**建一条 news;那次 `npm run build` 发生时该行还在,
于是 `/news` 的预渲染 HTML 把它烤了进去(`grep -c "E2E 测试新闻" dist/standalone/dist/server/app/news.html` = 2)。
用例的 teardown 之后删了行,但 `dist/` 里的静态产物不会自己回退 —— 基线没错,产物错了。
处置:`prisma/dev.db` 只剩 2 条真实新闻行 → 重建 → 产物 0 命中 → `/news` 5/5 通过。
**没有重采这 5 张**(重采等于把测试数据写进基线)。
教训(已可机械判定):`grep -c "E2E 测试新闻" dist/standalone/dist/server/app/news.html` 应为 0;
非 0 就先重建再谈视觉红。顺序纪律:**先跑写库型 E2E,再 build**,反过来就会把测试数据烤进产物。
### 补上一个真实的覆盖缺口
`/products/erp-upgrade-v3` 是遗留 hero 的两个调用点之一,但**视觉表里从来没有它** ——
磁盘上那 5 张 `product-erp-upgrade-v3-*` 基线是孤儿(有文件、无用例),所以退役 hero 时
改了它的首屏却没有任何守卫。本轮把它接进 `VISUAL_TEST_PAGES`,用 `changed` 重生成这 5 张
(复用同名文件,孤儿基线复活成有效基线),只读复跑 5/5 通过。
另一个调用点 `/products/standalone/[id]` 仍然**不可观测**:seed 库里没有 standalone 行,
`generateStaticParams` 产出为空 ⇒ 该路由 404。这条迁移只有类型检查 + 组件单测覆盖
(`detail-page-hero.test.tsx` 5 例),没有视觉证据 —— 不假装有。
### P5 后的全量读数
```
--workers=2 --update-snapshots=none → 125 passed / 0 failed
(新增 1 个用例 × 5 project 后,全量 130 例;上面 125 是加用例之前那一轮)
```
+4
View File
@@ -31,6 +31,10 @@ const VISUAL_TEST_PAGES = [
{ path: '/products/erp', name: 'product-erp', label: '产品详情-ERP' },
// 与 /products/erp 是不同路由:此前只在 Lighthouse URL 表里,视觉表缺它 ⇒ 同型覆盖缺口(验收 §8 限制⑦)
{ path: '/products/erp-upgrade', name: 'product-erp-upgrade', label: '产品 ERP 升级页' },
// 2026-11-03 补:这条路由此前遗留 hero 的 2 个调用点之一,但视觉表里从来没有它 ——
// 磁盘上那 5 张 `product-erp-upgrade-v3-*` 基线成了**孤儿**(有文件、无用例)。
// 退役遗留 hero 时顺手接上,否则改完这个页面没有任何视觉守卫。
{ path: '/products/erp-upgrade-v3', name: 'product-erp-upgrade-v3', label: '产品 ERP 升级页 v3' },
{ path: '/about/brand', name: 'about-brand', label: '品牌资产页' },
{ path: '/solutions', name: 'solutions', label: '解决方案列表' },
{ path: '/solutions/manufacturing', name: 'solution-manufacturing', label: '解决方案详情-制造' },
Binary file not shown.

Before

Width:  |  Height:  |  Size: 550 KiB

After

Width:  |  Height:  |  Size: 596 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 726 KiB

After

Width:  |  Height:  |  Size: 794 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 1.8 MiB

+1 -1
View File
@@ -93,7 +93,7 @@ const ALLOWLIST_INLINE_COLOR = [
{ file: THEME_SOURCE, color: '#0f3d3e', reason: '产品线视觉身份 novavis(受控例外,ADR-0008 决策五)' },
// —— 透传点:把真源色值写进内联 style 的两处。登记后,**新增透传点即判红**
// (比如哪天有人把产品线色相从徽章扩散到卡片描边)。
{ file: 'src/components/detail/detail-hero.tsx', color: 'theme.accentColor', reason: '唯一持有该身份的内联透传点(hero 徽章)' },
{ file: 'src/components/detail/detail-page-hero.tsx', color: 'theme.accentColor', reason: '唯一持有该身份的内联透传点(eyebrow 短线,2026-11-03 由旧 detail-hero 徽章迁来)' },
{ file: 'src/components/content/sections.tsx', color: 'theme.accentColor', reason: 'dataviz 构件的 accent 透传(默认值是品牌红,未被产品线覆盖)' },
];
@@ -3,7 +3,7 @@ import { getProductBySlug } from '@/lib/cms/data-server';
import { COMPANY_INFO } from '@/lib/constants';
import { DetailSwipeNav } from '@/components/ui/detail-swipe-nav';
import { CTA_LABELS } from '@/lib/constants/cta-labels';
import { DetailHero } from '@/components/detail/detail-hero';
import { DetailPageHero } from '@/components/detail/detail-page-hero';
import { ProductValueSection } from '@/components/detail/detail-product-value';
import { DetailTrustSection } from '@/components/detail/detail-trust-section';
import { DetailCTASection } from '@/components/detail/detail-cta-section';
@@ -52,7 +52,7 @@ export default async function ERPUpgradeV3Page() {
<div className="min-h-screen bg-[var(--color-bg-primary)]">
<DetailSwipeNav type="product" currentId={item.slug || 'erp'} />
<DetailHero
<DetailPageHero
theme={theme}
badge="企业旗舰系列"
title={title}
@@ -60,6 +60,7 @@ export default async function ERPUpgradeV3Page() {
description={overview}
primaryAction={{ label: CTA_LABELS.consult, href: '/contact' }}
secondaryAction={{ label: '查看方案', href: '/solutions' }}
testIdPrefix="erp-upgrade-hero"
/>
<ProductValueSection product={data as unknown as Product} />
@@ -3,7 +3,7 @@
import { getHeroTheme } from '@/lib/constants/hero-themes';
import { CTAButton } from '@/components/ui/cta-button';
import { CTA_LABELS } from '@/lib/constants/cta-labels';
import { DetailHero } from '@/components/detail/detail-hero';
import { DetailPageHero } from '@/components/detail/detail-page-hero';
import { DetailTrustSection } from '@/components/detail/detail-trust-section';
import { DetailCTASection } from '@/components/detail/detail-cta-section';
import { L3EmptyFallback } from '@/components/detail';
@@ -55,7 +55,7 @@ export function StandaloneProductClient({ item }: StandaloneProductClientProps)
<div className="min-h-screen">
<DetailSwipeNav type="product" currentId={id} />
<DetailHero
<DetailPageHero
theme={theme}
badge={badgeText}
title={title}
@@ -66,6 +66,7 @@ export function StandaloneProductClient({ item }: StandaloneProductClientProps)
: { label: '了解详情', href: '/contact' }
}
secondaryAction={{ label: '返回产品列表', href: '/products' }}
testIdPrefix="standalone-hero"
/>
{status === 'coming-soon' ? (
-208
View File
@@ -1,208 +0,0 @@
'use client';
import { motion } from 'framer-motion';
import { ArrowRight, Sparkles, ChevronDown } from 'lucide-react';
import type { HeroTheme } from '@/lib/constants/hero-themes';
import { PressableButton } from './micro-interactions';
interface DetailHeroProps {
theme: HeroTheme;
badge?: string;
title: string;
subtitle: string;
description?: string;
primaryAction?: { label: string; href: string };
secondaryAction?: { label: string; href: string };
/** Bain 式变体:'light' | 'brand'(深红背景) */
variant?: 'light' | 'brand';
}
export function DetailHero({
theme,
badge,
title,
subtitle,
description,
primaryAction,
secondaryAction,
variant = 'light',
}: DetailHeroProps) {
const isCenterLayout = theme.layout === 'center' || theme.layout === 'wide';
const isBrand = variant === 'brand';
const bgClass = isBrand
? 'bg-brand-section text-white'
: 'bg-bg-primary text-ink';
return (
<section className={`relative min-h-[700px] flex items-center overflow-hidden ${bgClass}`}>
{/* 品牌色背景纹理 */}
{isBrand && (
<div className="absolute inset-0 pointer-events-none opacity-[0.04]"
style={{
backgroundImage: `radial-gradient(circle at 25% 25%, rgba(255,255,255,0.3) 1px, transparent 1px)`,
backgroundSize: '48px 48px',
}}
/>
)}
<div className={`container-wide relative z-10 ${theme.layout === 'wide' ? 'py-36 lg:py-44' : 'py-32 lg:py-40'}`}>
<motion.div
initial="hidden"
animate="visible"
variants={{
hidden: {},
visible: {
transition: {
staggerChildren: 0.12,
delayChildren: 0.05,
},
},
}}
className={`max-w-4xl ${isCenterLayout ? 'mx-auto text-center' : ''}`}
>
{(badge || theme.badge) && (
<motion.div
variants={{
hidden: { opacity: 0, scale: 0.9, filter: 'blur(8px)' },
visible: {
opacity: 1,
scale: 1,
filter: 'blur(0px)',
transition: {
duration: 0.28,
ease: [0.22, 1, 0.36, 1] as const,
},
},
}}
className={`mb-8 inline-flex items-center gap-2.5 rounded-full px-5 py-2.5 text-xs font-semibold tracking-widest uppercase ${
isCenterLayout ? '' : ''
}`}
style={{
backgroundColor: `${theme.accentColor}10`,
// 文字色经 --badge-accent-text 间接引用:浅色取 accentColor 原色,
// 深色由 globals.css color-mix 自动提亮(accentColor 直用作深底文字会不可读)
color: 'var(--badge-accent-text)',
borderColor: `${theme.accentColor}25`,
'--badge-accent': theme.accentColor,
} as React.CSSProperties}
>
<span>
<Sparkles className="w-3.5 h-3.5" />
</span>
{badge || theme.badge}
</motion.div>
)}
<motion.h1
variants={{
hidden: { opacity: 0, y: 40, filter: 'blur(10px)' },
visible: {
opacity: 1,
y: 0,
filter: 'blur(0px)',
transition: {
duration: 0.28,
ease: [0.22, 1, 0.36, 1] as const,
},
},
}}
className={`text-4xl md:text-5xl lg:text-[3.75rem] font-bold tracking-tight leading-[1.1] mb-8 text-ink ${
isCenterLayout ? '' : ''
}`}
>
{title}
</motion.h1>
<motion.p
variants={{
hidden: { opacity: 0, y: 30 },
visible: {
opacity: 1,
y: 0,
transition: {
duration: 0.28,
delay: 0.25,
ease: [0.22, 1, 0.36, 1] as const,
},
},
}}
className="text-lg md:text-xl text-text-secondary leading-relaxed mb-5 max-w-3xl"
>
{subtitle}
</motion.p>
{description && (
<motion.p
variants={{
hidden: { opacity: 0, y: 24 },
visible: {
opacity: 1,
y: 0,
transition: {
duration: 0.28,
delay: 0.4,
ease: [0.22, 1, 0.36, 1] as const,
},
},
}}
className="text-base text-text-muted mt-5 max-w-2xl leading-relaxed"
>
{description}
</motion.p>
)}
{(primaryAction || secondaryAction) && (
<motion.div
variants={{
hidden: { opacity: 0, y: 24 },
visible: {
opacity: 1,
y: 0,
transition: {
duration: 0.28,
delay: 0.55,
ease: [0.22, 1, 0.36, 1] as const,
},
},
}}
className={`mt-12 flex flex-wrap gap-5 ${isCenterLayout ? 'justify-center' : ''}`}
>
{primaryAction && (
<PressableButton
href={primaryAction.href}
variant="primary"
className="px-10 py-4 text-base shadow-lg group"
>
<span>{primaryAction.label}</span>
<ArrowRight className="w-5 h-5 group-hover:translate-x-1 group-hover:-translate-y-0.5 transition-transform duration-normal" />
</PressableButton>
)}
{secondaryAction && (
<PressableButton
href={secondaryAction.href}
variant="secondary"
className="px-8 py-4 text-base"
>
{secondaryAction.label}
</PressableButton>
)}
</motion.div>
)}
</motion.div>
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ delay: 1.5, duration: 0.28 }}
className="absolute bottom-8 left-1/2 -translate-x-1/2"
>
<div
className="text-text-muted cursor-pointer hover:text-text-secondary transition-colors"
>
<ChevronDown className="w-6 h-6" />
</div>
</motion.div>
</div>
</section>
);
}
@@ -0,0 +1,85 @@
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import { DetailPageHero } from './detail-page-hero';
import type { HeroTheme } from '@/lib/constants/hero-themes';
const theme: HeroTheme = {
id: 'erp',
name: 'ERP',
accentColor: '#1e3a5f',
badge: '企业套装',
};
const base = {
theme,
title: '睿新 ERP 管理系统',
subtitle: '企业资源管理专家',
};
/**
* 这组用例同时是**旧实现的回归防线**:被取代的遗留 `DetailHero` 有四处与
* DESIGN.md / ADR-0008 冲突的做法,任何一处回来都应当在这里被判红 ——
* 光删文件不写防线,下一个"重构"就会把它抄回来。
*/
describe('DetailPageHero', () => {
it('标题走 h1,副标题与描述都在', () => {
render(<DetailPageHero {...base} description="覆盖采购到交付的全流程" />);
expect(screen.getByRole('heading', { level: 1 }).textContent).toBe(base.title);
expect(screen.getByText(base.subtitle)).toBeInTheDocument();
expect(screen.getByText('覆盖采购到交付的全流程')).toBeInTheDocument();
});
it('产品线色相只落在 eyebrow 短线上(3px 色条),不铺胶囊底纹', () => {
const { container } = render(<DetailPageHero {...base} />);
const bar = container.querySelector('span[aria-hidden="true"]') as HTMLElement;
expect(bar).toBeTruthy();
// 色值来自真源、此处只透传 —— check:accents 判据 B 的登记点就是这一处
expect(bar.style.backgroundColor).toBeTruthy();
expect(bar.className).toContain('h-[3px]');
// 旧实现:rounded-full 胶囊 + 6.3% alpha 底纹 + Sparkles 图标
expect(container.querySelector('.rounded-full')).toBeNull();
expect(container.innerHTML).toContain('ERP');
expect(bar.className).not.toContain('rounded-full');
});
it('badge 覆盖主题自带徽章;都不传时回落主题名', () => {
const { rerender } = render(<DetailPageHero {...base} badge="企业旗舰系列" />);
expect(screen.getByText('企业旗舰系列')).toBeInTheDocument();
rerender(<DetailPageHero {...base} />);
expect(screen.getByText('企业套装')).toBeInTheDocument();
rerender(<DetailPageHero {...base} theme={{ ...theme, badge: undefined }} />);
expect(screen.getByText('ERP')).toBeInTheDocument();
});
it('两轨 CTA 各自带 testid,href 原样透出;缺动作时整行不渲染', () => {
const { rerender } = render(
<DetailPageHero
{...base}
primaryAction={{ label: '预约咨询', href: '/contact' }}
secondaryAction={{ label: '查看方案', href: '/solutions' }}
testIdPrefix="erp-hero"
/>,
);
expect(screen.getByTestId('erp-hero-primary')).toHaveAttribute('href', '/contact');
expect(screen.getByTestId('erp-hero-secondary')).toHaveAttribute('href', '/solutions');
rerender(<DetailPageHero {...base} />);
expect(screen.queryByTestId('erp-hero-primary')).toBeNull();
});
it('回归防线:不回到满幅红面 / 700px 宣言档 / 装饰模糊 / 1.x 秒延迟', () => {
const { container } = render(
<DetailPageHero
{...base}
primaryAction={{ label: '预约咨询', href: '/contact' }}
/>,
);
const section = container.querySelector('section')!;
expect(section.className).toContain('bg-bg-primary');
expect(section.className).not.toContain('bg-brand-section');
expect(section.className).not.toContain('min-h-[700px]');
// 旧实现是 framer-motion 的 blur→0 入场 + delay 0.05/0.25/0.4/0.55/1.5
expect(container.innerHTML).not.toContain('blur(');
expect(container.querySelector('[style*="filter"]')).toBeNull();
});
});
+100
View File
@@ -0,0 +1,100 @@
import { CTAButton } from '@/components/ui/cta-button';
import type { HeroTheme } from '@/lib/constants/hero-themes';
/**
* 详情页首屏(Detail Page Hero)—— 取代 2026-11 之前那版遗留 `DetailHero`。
*
* 被取代的旧实现有四条与 ADR-0008/0009 直接冲突的做法,都是有据可查的:
* 1. `min-h-[700px]`:DESIGN.md「Layout · Hero 四档音量」明写叶子详情页是**紧凑引言**
* (无 min-h、`py-16 sm:py-20 lg:py-28`),旧实现按首页宣言档在做。
* 2. `rounded-full` 胶囊徽章 + `bg-brand-section`(当前 variant='brand' 时)满幅红面:
* 两家对标实测红只做按钮,满幅红面是本仓自造语法。
* 3. `Sparkles` 图标 + 模糊入场(`filter: blur(8px)` → 0)+ `delay: 1.5` 的滚动提示:
* 装饰性模糊与 1.x 秒等待都在禁止清单里。
* 4. 4 段错峰 delay(0.05/0.25/0.4/0.55)靠 staggerChildren 级联,实际观感是"逐个挤出来"。
*
* 本实现借用的是 v17 首页那套已经验证过的语法:白底、左对齐、40/64 声明、400/700 双字重、
* 实心 + 描边两轨 CTA、入场只做 280ms 的 fadeUp。
*
* **产品线色相(7 个受控例外)的落点从"胶囊徽章底纹"移到"eyebrow 短线"**:
* 一条 3px × 24px 的色条 + 一行中性标签。色相身份保留(`check:accents` 判据 B 的
* 透传点从旧 hero 迁到这里,按 文件+色值 登记),但可见面积从视口的 0.538% 降到发丝级,
* 不再需要靠 6.3% alpha 底纹去"不刺眼"。
*/
export interface DetailPageHeroAction {
label: string;
href: string;
}
export function DetailPageHero({
theme,
badge,
title,
subtitle,
description,
primaryAction,
secondaryAction,
testIdPrefix = 'detail-hero',
}: {
theme: HeroTheme;
/** 徽章文案(分类 / 状态)。省略时回落到主题自带的 badge 或主题名 */
badge?: string;
title: string;
subtitle: string;
description?: string;
primaryAction?: DetailPageHeroAction;
secondaryAction?: DetailPageHeroAction;
/** e2e/testid 前缀:`${prefix}-primary` / `${prefix}-secondary` */
testIdPrefix?: string;
}) {
const eyebrow = badge || theme.badge || theme.name;
return (
<section className="bg-bg-primary" data-testid={`${testIdPrefix}-section`}>
<div className="container-x py-16 sm:py-20 lg:py-28">
<div className="flex items-center gap-3">
{/* 产品线视觉身份的唯一落点:3px × 24px 短线。
色值来自真源(hero-themes.ts),此处只做透传 —— check:accents 判据 B 登记在此。 */}
<span
aria-hidden="true"
className="h-[3px] w-6 shrink-0"
style={{ backgroundColor: theme.accentColor }}
/>
<span className="text-[13px] font-medium tracking-[0.15em] text-text-muted uppercase">
{eyebrow}
</span>
</div>
<h1 className="mt-6 max-w-4xl text-3xl font-bold leading-[1.05] tracking-tight text-ink sm:text-4xl md:text-5xl lg:text-[3.5rem]">
{title}
</h1>
<p className="mt-6 max-w-2xl text-lg leading-relaxed text-text-secondary">{subtitle}</p>
{description && (
<p className="mt-3 max-w-2xl text-base leading-relaxed text-text-muted">{description}</p>
)}
{(primaryAction || secondaryAction) && (
<div className="mt-10 flex flex-wrap items-center gap-4">
{primaryAction && (
<CTAButton href={primaryAction.href} dataTestId={`${testIdPrefix}-primary`}>
{primaryAction.label}
</CTAButton>
)}
{secondaryAction && (
<CTAButton
href={secondaryAction.href}
variant="secondary"
dataTestId={`${testIdPrefix}-secondary`}
>
{secondaryAction.label}
</CTAButton>
)}
</div>
)}
</div>
</section>
);
}
-144
View File
@@ -184,13 +184,6 @@ const mockHeroTheme = {
badge: '企业套装',
};
const mockCenterTheme = {
...mockHeroTheme,
id: 'solution',
layout: 'center' as const,
badge: undefined,
};
const mockProduct = {
id: 'erp',
title: 'ERP 企业资源管理系统',
@@ -221,143 +214,6 @@ const mockProduct = {
// ─── Tests ───────────────────────────────────────────────────────────────
describe('DetailHero', () => {
it('should render title and subtitle', async () => {
const { DetailHero } = await import('./detail-hero');
render(
<DetailHero
theme={mockHeroTheme}
title="ERP 系统"
subtitle="企业资源管理专家"
/>
);
expect(screen.getByText('ERP 系统')).toBeInTheDocument();
expect(screen.getByText('企业资源管理专家')).toBeInTheDocument();
});
it('should render badge from theme', async () => {
const { DetailHero } = await import('./detail-hero');
render(
<DetailHero
theme={mockHeroTheme}
title="ERP"
subtitle="ERP Description"
/>
);
expect(screen.getByText('企业套装')).toBeInTheDocument();
});
it('should render badge prop overriding theme badge', async () => {
const { DetailHero } = await import('./detail-hero');
render(
<DetailHero
theme={mockHeroTheme}
badge="新版"
title="ERP"
subtitle="ERP Description"
/>
);
expect(screen.getByText('新版')).toBeInTheDocument();
});
it('should render description when provided', async () => {
const { DetailHero } = await import('./detail-hero');
render(
<DetailHero
theme={mockHeroTheme}
title="ERP"
subtitle="Expert"
description="Detailed description here"
/>
);
expect(screen.getByText('Detailed description here')).toBeInTheDocument();
});
it('should not render description when not provided', async () => {
const { DetailHero } = await import('./detail-hero');
const { container } = render(
<DetailHero
theme={mockHeroTheme}
title="ERP"
subtitle="Expert"
/>
);
// Should still render subtitle but no extra description paragraph
expect(screen.getByText('Expert')).toBeInTheDocument();
// The description text should not be present
expect(container.querySelector('section')?.children.length).toBeGreaterThan(0);
});
it('should render primary and secondary actions', async () => {
const { DetailHero } = await import('./detail-hero');
render(
<DetailHero
theme={mockHeroTheme}
title="ERP"
subtitle="Expert"
primaryAction={{ label: '了解更多', href: '/products/erp' }}
secondaryAction={{ label: '预约演示', href: '/contact' }}
/>
);
expect(screen.getByText('了解更多')).toBeInTheDocument();
expect(screen.getByText('预约演示')).toBeInTheDocument();
});
it('should not render actions when not provided', async () => {
const { DetailHero } = await import('./detail-hero');
render(
<DetailHero
theme={mockHeroTheme}
title="ERP"
subtitle="Expert"
/>
);
expect(screen.queryByText('了解更多')).not.toBeInTheDocument();
});
it('should render no badge when theme has no badge and no badge prop', async () => {
const { DetailHero } = await import('./detail-hero');
render(
<DetailHero
theme={mockCenterTheme}
title="Solution"
subtitle="Desc"
/>
);
// Center theme has no badge - verify sparkles (badge icon) is not in document
expect(screen.queryByText('企业套装')).not.toBeInTheDocument();
});
it('should render with center layout', async () => {
const { DetailHero } = await import('./detail-hero');
const { container } = render(
<DetailHero
theme={mockCenterTheme}
title="Solution"
subtitle="Desc"
/>
);
// Center layout renders text-center class
const section = container.querySelector('section');
expect(section).toBeInTheDocument();
});
it('should use theme-aware bg token (not hard-coded bg-white) for light variant', async () => {
const { DetailHero } = await import('./detail-hero');
const { container } = render(
<DetailHero
theme={mockHeroTheme}
title="ERP"
subtitle="Expert"
/>
);
// 暗黑模式:浅色底色必须走 CSS 变量 token,dark 下才能随主题反色
const section = container.querySelector('section');
expect(section?.className).toContain('bg-bg-primary');
expect(section?.className).not.toContain('bg-white');
});
});
describe('ProductValueSection', () => {
it('should render product title and overview', async () => {
const { ProductValueSection } = await import('./detail-product-value');
+1 -1
View File
@@ -1,4 +1,4 @@
export { DetailHero } from './detail-hero';
export { DetailPageHero } from './detail-page-hero';
export { ProductValueSection } from './detail-product-value';
-2
View File
@@ -31,8 +31,6 @@ export {
getSolutionCrossRefs,
getServiceCrossRefs,
type HeroTheme,
type HeroLayout,
type HeroTexture,
type CrossReference,
type MegaDropdownGroup,
SERVICE_COMMITMENTS,
-80
View File
@@ -1,21 +1,7 @@
export type HeroLayout = 'left' | 'center' | 'wide' | 'icon-left';
export interface HeroTexture {
type: 'grid' | 'data-flow' | 'layers' | 'shield-hex' | 'circuit' | 'none';
opacity: number;
color?: string;
}
export interface HeroTheme {
id: string;
name: string;
gradientFrom: string;
gradientTo: string;
gradientAngle: number;
accentColor: string;
accentBg: string;
texture: HeroTexture;
layout: HeroLayout;
badge?: string;
}
@@ -23,131 +9,65 @@ export const HERO_THEMES: Record<string, HeroTheme> = {
erp: {
id: 'erp',
name: 'ERP',
gradientFrom: '#f8f6f3',
gradientTo: '#f0ebe4',
gradientAngle: 135,
accentColor: '#1e3a5f',
accentBg: 'rgba(30, 58, 95, 0.06)',
texture: { type: 'grid', opacity: 0.03 },
layout: 'left',
badge: '企业套装',
},
crm: {
id: 'crm',
name: 'CRM',
gradientFrom: '#f7f5f2',
gradientTo: '#eee9e2',
gradientAngle: 120,
accentColor: '#1e40af',
accentBg: 'rgba(30, 64, 175, 0.06)',
texture: { type: 'layers', opacity: 0.03 },
layout: 'left',
badge: '企业套装',
},
bi: {
id: 'bi',
name: 'BI',
gradientFrom: '#FAF8F4',
gradientTo: '#EFEAE1',
gradientAngle: 145,
accentColor: '#0c4a6e',
accentBg: 'rgba(12, 74, 110, 0.06)',
texture: { type: 'data-flow', opacity: 0.03 },
layout: 'left',
badge: '企业套装',
},
cms: {
id: 'cms',
name: 'CMS',
gradientFrom: '#f5f8f5',
gradientTo: '#eaf0ea',
gradientAngle: 130,
accentColor: '#14532d',
accentBg: 'rgba(20, 83, 45, 0.06)',
texture: { type: 'layers', opacity: 0.03 },
layout: 'left',
badge: '企业套装',
},
sds: {
id: 'sds',
name: 'SDS',
gradientFrom: '#faf7f4',
gradientTo: '#f3ede5',
gradientAngle: 140,
accentColor: '#78350f',
accentBg: 'rgba(120, 53, 15, 0.06)',
texture: { type: 'data-flow', opacity: 0.03 },
layout: 'left',
badge: '企业套装',
},
oa: {
id: 'oa',
name: 'OA',
gradientFrom: '#f7f5fa',
gradientTo: '#efeaf5',
gradientAngle: 125,
accentColor: '#4c1d95',
accentBg: 'rgba(76, 29, 149, 0.06)',
texture: { type: 'grid', opacity: 0.03 },
layout: 'left',
badge: '企业套装',
},
novavis: {
id: 'novavis',
name: 'NovaVis',
gradientFrom: '#f4fafa',
gradientTo: '#e8f3f3',
gradientAngle: 150,
accentColor: '#0f3d3e',
accentBg: 'rgba(15, 61, 62, 0.06)',
texture: { type: 'data-flow', opacity: 0.04 },
layout: 'wide',
badge: '专业产品',
},
solution: {
id: 'solution',
name: '解决方案',
gradientFrom: '#f8f6f3',
gradientTo: '#f0ebe4',
gradientAngle: 150,
accentColor: '#C41E3A',
accentBg: 'rgba(196, 30, 58, 0.06)',
texture: { type: 'circuit', opacity: 0.02 },
layout: 'center',
},
service: {
id: 'service',
name: '服务',
gradientFrom: '#f7f5f2',
gradientTo: '#eee9e2',
gradientAngle: 135,
accentColor: '#C41E3A',
accentBg: 'rgba(196, 30, 58, 0.06)',
texture: { type: 'none', opacity: 0 },
layout: 'icon-left',
},
security: {
id: 'security',
name: '安全产品',
gradientFrom: '#faf5f5',
gradientTo: '#f5eded',
gradientAngle: 135,
accentColor: '#991b1b',
accentBg: 'rgba(153, 27, 27, 0.06)',
texture: { type: 'shield-hex', opacity: 0.03 },
layout: 'wide',
badge: '安全合规',
},
default: {
id: 'default',
name: '默认',
gradientFrom: '#f8f6f3',
gradientTo: '#f0ebe4',
gradientAngle: 140,
accentColor: '#C41E3A',
accentBg: 'rgba(196, 30, 58, 0.06)',
texture: { type: 'none', opacity: 0 },
layout: 'left',
},
};
+1 -1
View File
@@ -11,7 +11,7 @@ export type { TeamMember } from './team';
export { METHODOLOGY, type MethodologyPhase } from './methodology';
export { SOLUTIONS, type Solution } from './solutions';
export { CASE_INDUSTRIES, type CaseStudy, type CaseMetric, type CaseTimelinePhase, type CaseService, type CaseTestimonial } from './cases';
export { HERO_THEMES, getHeroTheme, type HeroTheme, type HeroLayout, type HeroTexture } from './hero-themes';
export { HERO_THEMES, getHeroTheme, type HeroTheme } from './hero-themes';
export { IMAGE_RATIOS, aspectStyle, aspectWidthStyle, type ImageRatio } from './image-ratios';
export { getProductCrossRefs, getSolutionCrossRefs, getServiceCrossRefs, type CrossReference } from './cross-references';
export {