refactor(MarketDataView): 提取共享组件,简化 Panel 结构
- 新增 shared 目录,提取重复组件: - DarkGoldCard: 黑金卡片容器 - DarkGoldBadge: 黑金徽章组件 - EmptyState: 空状态组件 - styles.ts: 共享样式定义 - 简化各 Panel 组件,移除重复代码 - 优化 index.tsx componentProps 传递 - 调整 hooks/services 数据获取逻辑 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,19 +1,14 @@
|
||||
// src/views/Company/components/MarketDataView/index.tsx
|
||||
// MarketDataView 主组件 - 股票市场数据综合展示
|
||||
|
||||
import React, { useState, useEffect, ReactNode, useMemo, useCallback } from 'react';
|
||||
import React, { useState, useEffect, ReactNode, useMemo, useCallback, memo } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Container,
|
||||
VStack,
|
||||
useDisclosure,
|
||||
} from '@chakra-ui/react';
|
||||
import {
|
||||
Unlock,
|
||||
ArrowUp,
|
||||
Star,
|
||||
Lock,
|
||||
} from 'lucide-react';
|
||||
import { Unlock, ArrowUp, Star, Lock } from 'lucide-react';
|
||||
|
||||
// 通用组件
|
||||
import SubTabContainer from '@components/SubTabContainer';
|
||||
@@ -36,7 +31,7 @@ import {
|
||||
PledgePanel,
|
||||
} from './components/panels';
|
||||
import LoadingState from '../LoadingState';
|
||||
import type { MarketDataViewProps, RiseAnalysis } from './types';
|
||||
import type { MarketDataViewProps } from './types';
|
||||
|
||||
/**
|
||||
* MarketDataView 主组件
|
||||
@@ -118,37 +113,16 @@ const MarketDataView: React.FC<MarketDataViewProps> = ({ stockCode: propStockCod
|
||||
{ key: 'pledge', name: '股权质押', icon: Lock, component: PledgePanel },
|
||||
];
|
||||
|
||||
// 传递给 Tab 组件的 props
|
||||
// 传递给 Tab 组件的 props - 只传递各 Tab 需要的数据
|
||||
const componentProps = useMemo(
|
||||
() => ({
|
||||
theme,
|
||||
tradeData,
|
||||
minuteData,
|
||||
minuteLoading,
|
||||
analysisMap,
|
||||
onLoadMinuteData: loadMinuteData,
|
||||
onChartClick: handleChartClick,
|
||||
selectedPeriod,
|
||||
onPeriodChange: setSelectedPeriod,
|
||||
// 各 Tab 只使用自己需要的数据
|
||||
fundingData,
|
||||
bigDealData,
|
||||
unusualData,
|
||||
pledgeData,
|
||||
}),
|
||||
[
|
||||
theme,
|
||||
tradeData,
|
||||
minuteData,
|
||||
minuteLoading,
|
||||
analysisMap,
|
||||
loadMinuteData,
|
||||
handleChartClick,
|
||||
selectedPeriod,
|
||||
fundingData,
|
||||
bigDealData,
|
||||
unusualData,
|
||||
pledgeData,
|
||||
]
|
||||
[fundingData, bigDealData, unusualData, pledgeData]
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -203,4 +177,4 @@ const MarketDataView: React.FC<MarketDataViewProps> = ({ stockCode: propStockCod
|
||||
);
|
||||
};
|
||||
|
||||
export default MarketDataView;
|
||||
export default memo(MarketDataView);
|
||||
|
||||
Reference in New Issue
Block a user