From 6797f54b6c70ec3002ec868de95e0e5f239d1f6a Mon Sep 17 00:00:00 2001 From: zdl <3489966805@qq.com> Date: Thu, 11 Dec 2025 17:37:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=88=98=E7=95=A5=E5=88=86=E6=9E=90Ui?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/StrategyAnalysisCard.tsx | 155 ++++++++++++------ 1 file changed, 105 insertions(+), 50 deletions(-) diff --git a/src/views/Company/components/CompanyOverview/DeepAnalysisTab/components/StrategyAnalysisCard.tsx b/src/views/Company/components/CompanyOverview/DeepAnalysisTab/components/StrategyAnalysisCard.tsx index fe411b5f..e01ed7dc 100644 --- a/src/views/Company/components/CompanyOverview/DeepAnalysisTab/components/StrategyAnalysisCard.tsx +++ b/src/views/Company/components/CompanyOverview/DeepAnalysisTab/components/StrategyAnalysisCard.tsx @@ -4,7 +4,7 @@ * 显示公司战略方向和战略举措 */ -import React from 'react'; +import React, { memo, useMemo } from 'react'; import { Card, CardBody, @@ -17,63 +17,118 @@ import { Icon, Grid, GridItem, + Center, } from '@chakra-ui/react'; -import { FaRocket } from 'react-icons/fa'; -import { DisclaimerBox } from '../atoms'; +import { FaRocket, FaChartBar } from 'react-icons/fa'; import type { Strategy } from '../types'; +// 样式常量 - 避免每次渲染创建新对象 +const CARD_STYLES = { + bg: 'transparent', + border: '1px solid', + borderColor: 'yellow.600', + shadow: 'md', +} as const; + +const CONTENT_BOX_STYLES = { + p: 4, + border: '1px solid', + borderColor: 'yellow.600', + borderRadius: 'md', +} as const; + +const EMPTY_BOX_STYLES = { + border: '1px dashed', + borderColor: 'yellow.600', + borderRadius: 'md', + py: 12, +} as const; + +const GRID_RESPONSIVE_COLSPAN = { base: 2, md: 1 } as const; + interface StrategyAnalysisCardProps { strategy: Strategy; - cardBg?: string; } -const StrategyAnalysisCard: React.FC = ({ - strategy, - cardBg, -}) => { - const purpleBg = 'purple.50'; - const orangeBg = 'orange.50'; +// 空状态组件 - 独立 memo 避免重复渲染 +const EmptyState = memo(() => ( + +
+ + + 战略数据更新中 + + 战略方向和具体举措数据将在近期更新 + + +
+
+)); - return ( - - - - - 战略分析 - - - - - - - - - 战略方向 - - - - {strategy.strategy_description || '暂无数据'} - - - - +EmptyState.displayName = 'StrategyEmptyState'; - - - - 战略举措 - - - - {strategy.strategic_initiatives || '暂无数据'} - - - - - - - - ); -}; +// 内容项组件 - 复用结构 +interface ContentItemProps { + title: string; + content: string; +} + +const ContentItem = memo(({ title, content }) => ( + + + {title} + + + + {content} + + + +)); + +ContentItem.displayName = 'StrategyContentItem'; + +const StrategyAnalysisCard: React.FC = memo( + ({ strategy }) => { + // 缓存数据检测结果 + const hasData = useMemo( + () => !!(strategy?.strategy_description || strategy?.strategic_initiatives), + [strategy?.strategy_description, strategy?.strategic_initiatives] + ); + + return ( + + + + + 战略分析 + + + + {!hasData ? ( + + ) : ( + + + + + + + + + )} + + + ); + } +); + +StrategyAnalysisCard.displayName = 'StrategyAnalysisCard'; export default StrategyAnalysisCard;