import { Ban, Compass, Crosshair, EyeOff, FileText, Loader2, MousePointerClick, Waypoints, X, } from "lucide-react"; import type { KnowledgeNote } from "@/core/knowledge/types"; import type { GraphNode } from "./graphTypes"; import { getEdgeInfo, getNodeKind, getNodeTitle, NODE_KIND_META, } from "./graphUtils"; const SOURCE_TYPE_ZH: Record = { thread: "对话沉淀", search: "搜索沉淀", tool: "工具结果", file: "文件导入", manual: "手动创建", report: "报告", }; const STATUS_ZH: Record = { draft: "草稿", approved: "已审核", archived: "已归档", }; export interface NeighborItem { node: GraphNode; relation: string; } interface GraphDetailPanelProps { node: GraphNode | null; degree: number; neighbors: NeighborItem[]; /** Note detail (only for note-type nodes; undefined while absent/loading). */ note: KnowledgeNote | undefined; noteLoading: boolean; /** Explore-mode context; null when in full mode. */ explore: { /** Depth of this node in the explore graph; null = not yet visible. */ depth: number | null; expanded: boolean; isRoot: boolean; } | null; onViewSource: (noteId: string) => void; onLocate: (id: string) => void; onHide: (id: string) => void; onBlacklist: (id: string) => void; onPickNeighbor: (id: string) => void; onExpandNode: (id: string) => void; onSetExploreRoot: (id: string) => void; onClose: () => void; } function formatTime(value: string | null | undefined): string { if (!value) return "—"; const date = new Date(value); if (Number.isNaN(date.getTime())) return value; return date.toLocaleString("zh-CN", { hour12: false }); } export function GraphDetailPanel(props: GraphDetailPanelProps) { const { node } = props; return ( ); } function DetailBody(props: GraphDetailPanelProps & { node: GraphNode }) { const { node, note } = props; const kind = getNodeKind(node); const kindMeta = NODE_KIND_META[kind]; const isNote = (node.type || "").toLowerCase() === "note"; return (

{getNodeTitle(node)}

{kindMeta.label} {node.category && node.category !== kindMeta.label ? ` · ${node.category}` : ""} 度数 {props.degree} {props.explore && props.explore.depth !== null ? ( <> {props.explore.isRoot ? "探索起点" : `第 ${props.explore.depth} 层`} {props.explore.expanded ? "已展开" : "可展开"} ) : null}
{props.noteLoading ? (
加载笔记详情...
) : null} {note?.summary ?

{note.summary}

: null} {note?.tags?.length ? (
{note.tags.map((tag) => ( #{tag} ))}
) : null} {note ? (
来源 {SOURCE_TYPE_ZH[note.source_type] ?? note.source_type} 状态 {STATUS_ZH[note.status] ?? note.status} 创建时间 {formatTime(note.created_at)} 更新时间 {formatTime(note.updated_at)} {note.created_by_name ? ( <> 创建人 {note.created_by_name} ) : null}
) : null}
{isNote ? ( ) : null} {props.explore ? ( <> ) : null}

关联节点({props.neighbors.length})

{props.neighbors.length === 0 ? (
该节点暂无可见的关联节点
) : (
{props.neighbors.map(({ node: neighbor, relation }) => { const neighborKind = NODE_KIND_META[getNodeKind(neighbor)]; const relationInfo = getEdgeInfo(relation); return (
props.onPickNeighbor(neighbor.id)} > {getNodeTitle(neighbor)} {relationInfo.zh}
); })}
)}
); }