import React, { useState } from 'react'; import { RuleBasedReport, RuleEvidence, TimeLayerScope } from '../core-engine/types'; interface AnalysisPanelProps { report: RuleBasedReport; activeScope: TimeLayerScope; onScopeChange: (scope: TimeLayerScope) => void; onClose: () => void; } const AnalysisPanel: React.FC = ({ report, activeScope, onScopeChange, onClose }) => { const [activeTab, setActiveTab] = useState<'overview' | 'topics' | 'audit'>('overview'); const currentReport = report.scopedReports[activeScope] || report.globalReport; return (
{/* 头部 */}

紫微斗数深度解析报告

静态引擎: static-v2.0.0 | 动态引擎: dynamic-v2.0.0
{/* 时间层切换栏 */}
{report.activeScopes.map(scope => { const labels: Record = { original: '本命全局', daXian: '大限(十年)', liuNian: '流年(当年)', liuYue: '流月', liuRi: '流日', liuShi: '流时' }; return ( ); })}
{/* Tab 切换 */}
{activeTab === 'overview' && ( <> {/* 1. 总览 */}

📊 命局总览 ({activeScope === 'original' ? '本命全局' : '当前时间层'})

{currentReport.synthesis.totalScore}
综合得分 (满分100)

{currentReport.output.overview.summary}

  • {currentReport.output.overview.strength}
  • {currentReport.output.overview.risk}
  • {currentReport.output.overview.focus}
{/* 2. 静态结论 */}

🏛️ 先天底色 (静态格局)

性格特质

{currentReport.output.staticBase.traits.join(' ')}

先天优势

    {currentReport.output.staticBase.pros.map((p, i) =>
  • {p}
  • )}

潜在隐患

    {currentReport.output.staticBase.cons.map((c, i) =>
  • {c}
  • )}
{/* 3. 动态结论 */}

🌪️ 后天推演 (动态四化)

引动宫位: {currentReport.output.dynamicTrend.triggeredPalaces.length > 0 ? currentReport.output.dynamicTrend.triggeredPalaces.join('、') : '无明显引动'}
风险与机遇链条:
    {currentReport.output.dynamicTrend.risksAndOps.length > 0 ? currentReport.output.dynamicTrend.risksAndOps.map((r, i) =>
  • {r}
  • ) :
  • 无明显动态链
  • }
{currentReport.output.dynamicTrend.timing}
{/* 4. 天纪处方 */}

📜 天纪派处方建议

    {currentReport.output.prescriptions.map((adv, i) => (
  • {adv}
  • ))}
{/* 5. 能力边界标识 */}

ℹ️ 推演层级与能力边界说明

  • 已推演:本命盘静态格局、生年四化、大限流年流月流日流时全时间层引动、天纪派断语字典接入、静动态综合评分、全报告时间层切换。
  • 待接入:外部规则知识库检索(已预留 `KnowledgeSource` 接口)、体用链深度推演。
)} {activeTab === 'topics' && (
{/* 核心专题展示 */}

🎯 核心人生专题 ({activeScope === 'original' ? '本命盘' : '当前时间层'})

{Object.entries({ '事业 (官禄)': currentReport.static.topics.career, '财富 (财帛)': currentReport.static.topics.wealth, '婚姻 (夫妻)': currentReport.static.topics.marriage, '健康 (疾厄)': currentReport.static.topics.health, '资产 (田宅)': currentReport.static.topics.property, }).map(([title, evidences]) => (

{title}

{evidences.length > 0 ? (
    {evidences.map((ev, idx) => (
  • {ev.title}: {ev.description}
  • ))}
) : (
该专题在本层未见明显吉凶极端组合,属平稳态。
)}
))}
)} {activeTab === 'audit' && (
{/* 分项得分雷达图替代文字 */}

维度得分明细 ({activeScope === 'original' ? '本命全局' : '当前时间层'})

事业{currentReport.synthesis.dimensionScores.career}
财富{currentReport.synthesis.dimensionScores.wealth}
婚姻{currentReport.synthesis.dimensionScores.marriage}
健康{currentReport.synthesis.dimensionScores.health}
置信度评估{currentReport.synthesis.confidence}
{/* 规则审计列表 */}

触发规则证据链 (Audit Log)

{currentReport.allEvidences.map((ev, i) => ( ))}
)}
); }; const RuleCard: React.FC<{ evidence: RuleEvidence }> = ({ evidence }) => { const [expanded, setExpanded] = useState(false); const isPositive = evidence.scoreImpact > 0; const isNegative = evidence.scoreImpact < 0; return (
setExpanded(!expanded)} >
{evidence.title} {evidence.type}
{evidence.scoreImpact > 0 ? '+' : ''}{evidence.scoreImpact}
{expanded && (
结论描述: {evidence.description}
{evidence.boardEvidence.length > 0 && (
盘面证据:
    {evidence.boardEvidence.map((b, i) =>
  • {b}
  • )}
)} {evidence.conflicts && evidence.conflicts.length > 0 && (
冲突制化项:
    {evidence.conflicts.map((c, i) =>
  • {c}
  • )}
)}
Rule ID: {evidence.ruleId}
{evidence.tags.map((tag, i) => ( {tag} ))}
)}
); }; export default AnalysisPanel;