diff --git a/frontend/src/pages/Regime.tsx b/frontend/src/pages/Regime.tsx index 411bcd9..e34107e 100644 --- a/frontend/src/pages/Regime.tsx +++ b/frontend/src/pages/Regime.tsx @@ -95,7 +95,12 @@ function useEChart(option: echarts.EChartsOption | null, deps: unknown[]) { if (!instRef.current) { instRef.current = echarts.init(ref.current, undefined, { renderer: 'canvas' }) } - if (option) instRef.current.setOption(option, { notMerge: true }) + if (option) { + instRef.current.setOption(option, { notMerge: true }) + // 容器可能经历 display:none(tab 隐藏) → 可见的切换, 画布尺寸需要按当前 + // 容器实际尺寸重算; 调用方把 view 等显隐依赖传入 deps 以触发本 effect。 + instRef.current.resize() + } }, [option, ...deps]) return ref } @@ -119,6 +124,9 @@ const cardCls = 'rounded-card border border-border bg-surface/80 shadow-[0_1px_2 export function Regime() { const qc = useQueryClient() const [range, setRange] = useState('1y') + // 视图 tab: 市场环境(状态/趋势/日历) 与 情绪周期(阶段/主线) 两组内容同页切换, + // 避免单页过长需要大幅滚动。两组共用时间范围与重算入口。 + const [view, setView] = useState<'regime' | 'phase'>('regime') const [customOpen, setCustomOpen] = useState(false) // 日历热力图显示模式: false=单行(月份网格横向排列+滚动条, 默认), true=展开(换行完整网格) const [calendarExpanded, setCalendarExpanded] = useState(false) @@ -293,7 +301,7 @@ export function Regime() { ], } }, [rows, days, ct, hasPhaseData]) - const phaseChartRef = useEChart(phaseOption, [phaseOption]) + const phaseChartRef = useEChart(phaseOption, [phaseOption, view]) // 趋势图: 综合分主线 + 4 子维度曲线(可切换) + 状态背景色带 + 涨停数柱状 const trendOption = useMemo(() => { @@ -385,7 +393,7 @@ export function Regime() { ], } }, [rows, days, ct]) - const trendRef = useEChart(trendOption, [trendOption]) + const trendRef = useEChart(trendOption, [trendOption, view]) // 状态分布饼图 const pieOption = useMemo(() => { @@ -420,7 +428,7 @@ export function Regime() { }], } }, [states.data, ct]) - const pieRef = useEChart(pieOption, [pieOption]) + const pieRef = useEChart(pieOption, [pieOption, view]) // 日历热力图数据: 按月分组(纯 CSS 渲染, 不依赖 echarts calendar 的跨年怪异行为)。 // 结构: [{ year, month, label, weeks: [[cell|gap]×7]×N }] @@ -500,7 +508,9 @@ export function Regime() {

市场环境

- 每日环境状态 · 赚钱效应 · 趋势分析 + + {view === 'phase' ? '涨停情绪 · 市场阶段 · 主线脉络' : '每日环境状态 · 赚钱效应 · 趋势分析'} +
{/* 时间范围按钮组 */}
@@ -541,6 +551,24 @@ export function Regime() {
+ {/* ── 视图切换: 市场环境 / 情绪周期 (两组内容 tab 隔离, 减少单页高度) ── */} +
+
+ {([['regime', '市场环境', Activity], ['phase', '情绪周期', Flame]] as const).map(([k, label, Icon]) => ( + + ))} +
+ 两组内容同页切换 · 共用时间范围 +
+ + {/* ══ 情绪周期 tab: 阶段概览 + 时间轴 + 阶段×主线 + 主线排行 ══ */} +
+ {/* ── 市场阶段概览 (情绪周期 + 梯队指标 + 当前主线) ── */} {hasPhaseData && latest ? (
@@ -742,6 +770,11 @@ export function Regime() {
+
{/* /情绪周期 tab */} + + {/* ══ 市场环境 tab: 最新日概览 + 状态时间轴 + 趋势/分布 + 日历热力图 ══ */} +
+ {/* ── 最新日概览 (4 个指标卡, 去掉与看板重复的涨停/涨跌/成交额) ── */} {latest ? (
@@ -962,6 +995,8 @@ export function Regime() {
)} +
{/* /市场环境 tab */} + {/* ── 自定义天数弹窗 ── */} {customOpen && (