@@ -118,7 +123,7 @@ function MetricCard({
);
}
-export function ProductValueSection({ product }: ProductValueSectionProps) {
+export function ProductValueSection({ product, showDataProofs = true }: ProductValueSectionProps) {
return (
@@ -246,7 +251,7 @@ export function ProductValueSection({ product }: ProductValueSectionProps) {
{/* 数据证明 */}
- {product.dataProofs && product.dataProofs.length > 0 && (
+ {showDataProofs && product.dataProofs && product.dataProofs.length > 0 && (
{
if (!isInView) return;
- const numericValue = parseFloat(value.replace(/[^0-9.]/g, ''));
- if (isNaN(numericValue)) {
+ const parsed = parseMetricValue(value);
+ const numericValue = parsed.numeric;
+ if (numericValue === null) {
setDisplayValue(value);
return;
}
-
- const [, prefix = '', suffix = ''] = value.match(/^([^\d.]*)[\d.]+([^\d.]*)$/) ?? [];
+ const { prefix, suffix } = parsed;
const finalText =
prefix +
(Number.isInteger(numericValue) ? numericValue.toString() : numericValue.toFixed(1)) +
diff --git a/src/components/detail/detail.test.tsx b/src/components/detail/detail.test.tsx
index f3a815d9..1ac8d014 100644
--- a/src/components/detail/detail.test.tsx
+++ b/src/components/detail/detail.test.tsx
@@ -314,6 +314,38 @@ describe('ProductValueSection', () => {
}
});
+ // ── DEF-06/07:区间/多数字指标不得被拼成一个数 ──
+ describe('指标计数动画的取值解析(DEF-06/07)', () => {
+ it('区间值 `3-6个月` 不被渲染成 `36`', async () => {
+ const { ProductValueSection } = await import('./detail-product-value');
+ const rangeProduct = {
+ ...mockProduct,
+ dataProofs: [{ metric: '实施周期', value: '3-6个月', description: '典型交付周期' }],
+ };
+ render();
+ // 旧实现 `value.replace(/[^0-9.]/g,'')` ⇒ 36,`-` 与 `个月` 被丢掉
+ expect(screen.queryByText('36')).not.toBeInTheDocument();
+ expect(screen.getByText(/3-6个月/)).toBeInTheDocument();
+ });
+
+ it('DetailTrustSection 的计数器同样不把 `3–6 个月` 拼成 `36`', async () => {
+ const { DetailTrustSection } = await import('./detail-trust-section');
+ render(
+
+ );
+ expect(screen.queryByText('36')).not.toBeInTheDocument();
+ expect(screen.getByText(/3–6 个月/)).toBeInTheDocument();
+ });
+ });
+
+ it('showDataProofs=false 时整块不渲染(V3 去重)', async () => {
+ const { ProductValueSection } = await import('./detail-product-value');
+ render();
+ expect(screen.queryByText('以可量化的目标约束交付')).not.toBeInTheDocument();
+ });
+
});
describe('DetailTrustSection', () => {