MCPcopy Create free account
hub / github.com/APIParkLab/APIPark / nodesFormatter

Function nodesFormatter

frontend/packages/common/src/utils/systemRunning.ts:42–79  ·  view source on GitHub ↗
(
  nodes,
  isSelfSpace = true
)

Source from the content-addressed store, hash-verified

40// }
41
42export const nodesFormatter: (nodes: TopologyProjectItem[], isSelfSpace?: boolean) => NodeData[] = (
43 nodes,
44 isSelfSpace = true
45) => {
46 return nodes
47 .filter((item) => item)
48 .map((item) => {
49 if (isSelfSpace === undefined) {
50 isSelfSpace = true
51 }
52 const theme = isSelfSpace ? SELF_SPACE_CONTENT_COLOR : OUT_SPACE_CONTENT_COLOR
53 const name = `${item.name}`
54 const nodeData: NodeData = {
55 id: item.id,
56 label: fittingString(name, 150, RELATIVE_PICTURE_NODE_FONTSIZE),
57 name: name,
58 isSelfSpace,
59 isApp: item.isApp,
60 isServer: item.isServer,
61 x: 250,
62 y: 150,
63 title: name,
64 style: {
65 // 自身空间内的边框颜色和其他空间的边框颜色不一致
66 stroke: theme,
67 border: theme,
68 fill: isSelfSpace ? SELF_SPACE_THEME : OUT_SPACE_THEME
69 },
70 stateStyles: {
71 selected: {
72 // 选中状态的颜色
73 fill: theme
74 }
75 }
76 }
77 return nodeData
78 })
79}
80/**
81 * @description
82 */

Callers 1

relativeFormatterFunction · 0.90

Calls 1

fittingStringFunction · 0.85

Tested by

no test coverage detected