refactor: 重构前端代码并增加注释

This commit is contained in:
2026-04-06 14:24:45 +08:00
parent 882e14a47b
commit 120edca338
13 changed files with 463 additions and 312 deletions
+18
View File
@@ -0,0 +1,18 @@
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;
};