You've already forked DataMate
核心功能: - G6 v5 力导向图,支持交互式缩放、平移、拖拽 - 5 种布局模式:force, circular, grid, radial, concentric - 双击展开节点邻居到图中(增量探索) - 全文搜索,类型过滤,结果高亮(变暗/高亮状态) - 节点详情抽屉:实体属性、别名、置信度、关系列表(可导航) - 关系详情抽屉:类型、源/目标、权重、置信度、属性 - 查询构建器:最短路径/全路径查询,可配置 maxDepth/maxPaths - 基于 UUID 的图加载(输入或 URL 参数 ?graphId=...) - 大图性能优化(200 节点阈值,超过时禁用动画) 新增文件(13 个): - knowledge-graph.model.ts - TypeScript 接口,匹配 Java DTOs - knowledge-graph.api.ts - API 服务,包含所有 KG REST 端点 - knowledge-graph.const.ts - 实体类型颜色、关系类型标签、中文显示名称 - graphTransform.ts - 后端数据 → G6 节点/边格式转换 + 合并工具 - graphConfig.ts - G6 v5 图配置(节点/边样式、行为、布局) - hooks/useGraphData.ts - 数据钩子:加载子图、展开节点、搜索、合并 - hooks/useGraphLayout.ts - 布局钩子:5 种布局类型 - components/GraphCanvas.tsx - G6 v5 画布,力导向布局,缩放/平移/拖拽 - components/SearchPanel.tsx - 全文实体搜索,类型过滤 - components/NodeDetail.tsx - 实体详情抽屉 - components/RelationDetail.tsx - 关系详情抽屉 - components/QueryBuilder.tsx - 路径查询构建器 - Home/KnowledgeGraphPage.tsx - 主页面,整合所有组件 修改文件(5 个): - package.json - 添加 @antv/g6 v5 依赖 - vite.config.ts - 添加 /knowledge-graph 代理规则 - auth/permissions.ts - 添加 knowledgeGraphRead/knowledgeGraphWrite - pages/Layout/menu.tsx - 添加知识图谱菜单项(Network 图标) - routes/routes.ts - 添加 /data/knowledge-graph 路由 新增文档(10 个): - docs/knowledge-graph/ - 完整的知识图谱设计文档 Bug 修复(Codex 审查后修复): - P1: 详情抽屉状态与选中状态不一致(显示旧数据) - P1: 查询构建器未实现(最短路径/多路径查询) - P2: 实体类型映射 Organization → Org(匹配后端) - P2: getSubgraph depth 参数无效(改用正确端点) - P2: AllPathsVO 字段名不一致(totalPaths → pathCount) - P2: 搜索取消逻辑无效(传递 AbortController.signal) - P2: 大图性能优化(动画降级) - P3: 移除未使用的类型导入 构建验证: - tsc --noEmit ✅ clean - eslint ✅ 0 errors/warnings - vite build ✅ successful
82 lines
1.5 KiB
TypeScript
82 lines
1.5 KiB
TypeScript
export interface GraphEntity {
|
|
id: string;
|
|
name: string;
|
|
type: string;
|
|
description?: string;
|
|
labels?: string[];
|
|
aliases?: string[];
|
|
properties?: Record<string, unknown>;
|
|
sourceId?: string;
|
|
sourceType?: string;
|
|
graphId: string;
|
|
confidence?: number;
|
|
createdAt?: string;
|
|
updatedAt?: string;
|
|
}
|
|
|
|
export interface EntitySummaryVO {
|
|
id: string;
|
|
name: string;
|
|
type: string;
|
|
description?: string;
|
|
}
|
|
|
|
export interface EdgeSummaryVO {
|
|
id: string;
|
|
sourceEntityId: string;
|
|
targetEntityId: string;
|
|
relationType: string;
|
|
weight?: number;
|
|
}
|
|
|
|
export interface SubgraphVO {
|
|
nodes: EntitySummaryVO[];
|
|
edges: EdgeSummaryVO[];
|
|
nodeCount: number;
|
|
edgeCount: number;
|
|
}
|
|
|
|
export interface RelationVO {
|
|
id: string;
|
|
sourceEntityId: string;
|
|
sourceEntityName: string;
|
|
sourceEntityType: string;
|
|
targetEntityId: string;
|
|
targetEntityName: string;
|
|
targetEntityType: string;
|
|
relationType: string;
|
|
properties?: Record<string, unknown>;
|
|
weight?: number;
|
|
confidence?: number;
|
|
sourceId?: string;
|
|
graphId: string;
|
|
createdAt?: string;
|
|
}
|
|
|
|
export interface SearchHitVO {
|
|
id: string;
|
|
name: string;
|
|
type: string;
|
|
description?: string;
|
|
score: number;
|
|
}
|
|
|
|
export interface PagedResponse<T> {
|
|
page: number;
|
|
size: number;
|
|
totalElements: number;
|
|
totalPages: number;
|
|
content: T[];
|
|
}
|
|
|
|
export interface PathVO {
|
|
nodes: EntitySummaryVO[];
|
|
edges: EdgeSummaryVO[];
|
|
pathLength: number;
|
|
}
|
|
|
|
export interface AllPathsVO {
|
|
paths: PathVO[];
|
|
pathCount: number;
|
|
}
|