import { Button, Empty, Tag, Typography, Space, Alert, Tooltip } from 'antd' import { LinkOutlined, ThunderboltOutlined } from '@ant-design/icons' import type { DeconstructPointsVO, HighValuePoint } from '../api/types' const { Text, Paragraph } = Typography interface Props { data: DeconstructPointsVO | null loading?: boolean /** 第二个参数 configCode 优先于 dropdown 的选择 */ onRecallByText: (text: string, configCodeOverride?: string) => void } const TYPE_COLOR: Record = { 灵感点: 'blue', 目的点: 'gold', 关键点: 'green', } /** 当前后端只支持 VIDEO_TOPIC 和 VIDEO_INSPIRATION 两个维度 */ const SUPPORTED_TYPES = new Set(['灵感点']) const UNSUPPORTED_TIP = '暂仅支持 灵感点 整条召回; 关键点/目的点 暂未配置向量维度' const UNSUPPORTED_WORD_TIP = '暂不支持词级召回(尚未配置词级向量维度)' /** * 按钮纵向对齐: 所有按钮保持同样的右边缘 + 同样的宽度 * 父级(选题/灵感点/关键点/目的点)用 size="middle" 默认高度 → 视觉更突出 * 子级(实质词召回)用 size="small" → 字体更小,视觉退一级 * 两者宽度都=110, 都带闪电图标, 右对齐 */ const BTN_WIDTH = 110 /** 父级生效: 绿色实色 */ const ACTIVE_PARENT_BTN_STYLE: React.CSSProperties = { width: BTN_WIDTH, background: '#52c41a', borderColor: '#52c41a', color: '#fff', flexShrink: 0, } /** 父级 disabled: 灰色 */ const DISABLED_PARENT_BTN_STYLE: React.CSSProperties = { width: BTN_WIDTH, flexShrink: 0, } /** 子级 disabled: 字体小,灰色 */ const DISABLED_CHILD_BTN_STYLE: React.CSSProperties = { width: BTN_WIDTH, flexShrink: 0, fontSize: 12, } /** * 展示后端 getDeconstructPoints 返回的"实质≥0.8 高价值点" * * 召回策略: * - 选题"以此选题召回" → VIDEO_TOPIC (生效) * - 灵感点行"以此召回" → VIDEO_INSPIRATION (生效, 卡片绿色背景) * - 关键点 / 目的点 整条 → disabled 灰色, 灰色背景 * - 任何点下的实质词"召回" → disabled 灰色 (暂不支持词级) */ export default function DeconstructTree({ data, loading, onRecallByText }: Props) { if (loading) return
加载中...
if (!data) { return } return ( {/* 选题 */} {data.topic && (
选题
{data.topic}
)} {/* 权重可视化链接 */} {data.htmlUrl && ( } message={ 查看带权重的可视化页面 } style={{ padding: '6px 12px' }} /> )} {/* 高价值点 */} {data.highValuePoints && data.highValuePoints.length > 0 ? ( {data.highValuePoints.map((p) => ( ))} ) : ( )} ) } function PointCard({ point, onRecallByText, }: { point: HighValuePoint onRecallByText: (t: string, code?: string) => void }) { const color = TYPE_COLOR[point.type] || 'default' const supported = SUPPORTED_TYPES.has(point.type) // 整条召回按钮 (生效 vs 灰色) - 父级,默认中号 const headerBtn = supported ? ( ) : ( ) return (
{point.type} {point.name} {headerBtn}
{point.id}
{/* 实质词 - 纵向一列, 召回按钮右对齐, 全部 disabled */} {point.essences.map((e) => (
{e.word} = 0.9 ? 'red' : e.score >= 0.85 ? 'orange' : 'gold'} style={{ margin: 0 }} > {e.score.toFixed(2)} {/* 推到右边,所有按钮 width=110 对齐 */}
))}
) }