31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
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 NODE_TYPE_LABELS: Record<string, { zh: string; en: string }> = {
|
|
'概念': { zh: '概念', en: 'Concept' },
|
|
'工具': { zh: '工具', en: 'Tool' },
|
|
'应用': { zh: '应用', en: 'Application' },
|
|
};
|
|
|
|
// 获取节点颜色配置
|
|
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;
|
|
};
|
|
|
|
// 获取节点双语标签
|
|
export const getNodeLabels = (type: string): { zh: string; en: string } => {
|
|
return NODE_TYPE_LABELS[type] || { zh: type, en: type };
|
|
};
|