From cd7abc89e2b3c051f8cb460976431d6701579fd9 Mon Sep 17 00:00:00 2001 From: zdl <3489966805@qq.com> Date: Fri, 5 Dec 2025 11:55:13 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=8F=90=E5=8F=96=20K=20=E7=BA=BF?= =?UTF-8?q?=E5=9B=BE=E5=BC=B9=E7=AA=97=E5=85=B1=E4=BA=AB=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=88=B0=20types.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新建 types.ts 存放 StockInfo 接口和图表常量 - KLineChartModal.tsx: 移除内联 StockInfo 定义,改为从 types 导入 - TimelineChartModal.tsx: 移除内联 StockInfo 定义,改为从 types 导入 - 减少代码重复,统一类型管理 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/components/StockChart/KLineChartModal.tsx | 9 +-- .../StockChart/TimelineChartModal.tsx | 9 +-- src/components/StockChart/types.ts | 56 +++++++++++++++++++ 3 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 src/components/StockChart/types.ts diff --git a/src/components/StockChart/KLineChartModal.tsx b/src/components/StockChart/KLineChartModal.tsx index 68bfa502..c303d517 100644 --- a/src/components/StockChart/KLineChartModal.tsx +++ b/src/components/StockChart/KLineChartModal.tsx @@ -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 diff --git a/src/components/StockChart/TimelineChartModal.tsx b/src/components/StockChart/TimelineChartModal.tsx index f38302cb..5328e551 100644 --- a/src/components/StockChart/TimelineChartModal.tsx +++ b/src/components/StockChart/TimelineChartModal.tsx @@ -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 diff --git a/src/components/StockChart/types.ts b/src/components/StockChart/types.ts new file mode 100644 index 00000000..b120812b --- /dev/null +++ b/src/components/StockChart/types.ts @@ -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;