refactor: 提取 K 线图弹窗共享类型到 types.ts

- 新建 types.ts 存放 StockInfo 接口和图表常量
- KLineChartModal.tsx: 移除内联 StockInfo 定义,改为从 types 导入
- TimelineChartModal.tsx: 移除内联 StockInfo 定义,改为从 types 导入
- 减少代码重复,统一类型管理

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
zdl
2025-12-05 11:55:13 +08:00
parent 1351d2626a
commit cd7abc89e2
3 changed files with 58 additions and 16 deletions

View File

@@ -6,14 +6,7 @@ import * as echarts from 'echarts';
import dayjs from 'dayjs';
import { stockService } from '@services/eventService';
import { selectIsMobile } from '@store/slices/deviceSlice';
/**
* 股票信息
*/
interface StockInfo {
stock_code: string;
stock_name?: string;
}
import { StockInfo } from './types';
/**
* KLineChartModal 组件 Props

View File

@@ -21,14 +21,7 @@ import * as echarts from 'echarts';
import dayjs from 'dayjs';
import { klineDataCache, getCacheKey, fetchKlineData } from '@views/Community/components/StockDetailPanel/utils/klineDataCache';
import { selectIsMobile } from '@store/slices/deviceSlice';
/**
* 股票信息
*/
interface StockInfo {
stock_code: string;
stock_name?: string;
}
import { StockInfo } from './types';
/**
* TimelineChartModal 组件 Props

View File

@@ -0,0 +1,56 @@
// src/components/StockChart/types.ts
// 图表弹窗共享类型和常量
/**
* 股票信息(两个组件共用)
*/
export interface StockInfo {
stock_code: string;
stock_name?: string;
}
/**
* 图表颜色常量
*/
export const CHART_COLORS = {
background: '#1a1a1a',
border: '#404040',
text: '#e0e0e0',
textSecondary: '#999',
gridLine: '#2a2a2a',
up: '#ef5350', // 涨
down: '#26a69a', // 跌
accent: '#ffd700', // 金色强调
avgLine: '#ffa726', // 均价线
priceLine: '#2196f3', // 价格线
} as const;
/**
* Modal 样式常量
*/
export const MODAL_STYLES = {
border: '2px solid #ffd700',
boxShadow: '0 0 30px rgba(255, 215, 0, 0.5)',
borderRadius: { mobile: '12px', desktop: '8px' },
maxHeight: '85vh',
width: { mobile: '96vw', desktop: '90vw' },
} as const;
/**
* Tooltip 样式
*/
export const TOOLTIP_STYLES = {
backgroundColor: 'rgba(30, 30, 30, 0.95)',
borderColor: '#404040',
borderWidth: 1,
textStyle: { color: '#e0e0e0' },
} as const;
/**
* 轴线样式
*/
export const AXIS_STYLES = {
lineColor: '#404040',
labelColor: '#999',
fontSize: { mobile: 10, desktop: 12 },
} as const;