Files
knowledge-graph-agent/frontend/src/config/colors.ts
T

19 lines
727 B
TypeScript
Raw Normal View History

2026-04-06 14:24:45 +08:00
import type { Node } from '../types/graph';
// 节点类型颜色配置
// 用于统一管理知识图谱中不同类型节点的视觉样式
export const NODE_COLOR_MAP: Record<string, { fill: string; stroke: string }> = {
'概念': { fill: '#4ECDC4', stroke: '#45B7B0' },
'工具': { fill: '#FFA07A', stroke: '#FF7F50' },
'应用': { fill: '#2ECC71', stroke: '#27AE60' },
};
// 默认节点颜色(当类型未匹配时)
export const DEFAULT_NODE_COLORS = { fill: '#C6E5FF', stroke: '#5B8FF9' };
// 获取节点颜色配置
export const getNodeColors = (node: Node): { fill: string; stroke: string } => {
if (!node.type) return DEFAULT_NODE_COLORS;
return NODE_COLOR_MAP[node.type] || DEFAULT_NODE_COLORS;
};