MCPcopy Create free account
hub / github.com/MankaiHuang/screen-visualization / find

Function find

src/pages/Workspace/BluePrint.jsx:232–308  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

230 const getChildrenProperty = (saveNodeData, startNode) => {
231 // 根据起始node获取所有连接的node
232 const find = (node) => {
233 const edgeSourceNode = findEdgesById(saveNodeData.edges, node.id, 'source')
234 const result = edgeSourceNode.map(item => {
235 const start = {
236 id: node.id,
237 type: node.type,
238 property: { ...{}, ...getSetNodeProperty(node.id, node.type) },
239 }
240
241 const temp = []
242 const nowTargetNode = findNodeById(saveNodeData.nodes, item.target)
243 const sourceActionName = getActionNameByAnchor(node.type, item.sourceAnchor) // node出发的action
244 if (!start[sourceActionName]) {
245 start[sourceActionName] = []
246 }
247 const isEnd = targetNodeIsEnd(nowTargetNode) // 是否为结束node
248 if (!isEnd) {
249 const tempResult = find(nowTargetNode)
250 if (tempResult.length > 0) {
251 if (tempResult.length > 1) {
252 const uniqueArr = [] // 相同id 不同事件进行合并
253 tempResult.forEach((tep) => {
254 const targetArr = uniqueArr.find(v => v.id === tep.id)
255 if (targetArr) {
256 for (const i in tep) {
257 if (targetArr[i] && Object.prototype.toString.call(targetArr[i]) === '[object Array]') {
258 if (Object.prototype.toString.call(tep[i]) === '[object Array]') {
259 targetArr[i] = [...targetArr[i], ...tep[i]]
260 } else {
261 targetArr[i].push(tep[i])
262 }
263 }
264 else if (!targetArr[i]) {
265 targetArr[i] = tep[i]
266 }
267 }
268 } else {
269 uniqueArr.push(tep)
270 }
271 })
272 start[sourceActionName].push(uniqueArr)
273 } else {
274 start[sourceActionName].push(tempResult[0])
275 }
276 }
277 } else {
278 start[sourceActionName].push({
279 id: nowTargetNode.id,
280 type: nowTargetNode.type,
281 property: { ...{}, ...getSetNodeProperty(nowTargetNode.id, nowTargetNode.type) },
282 actionName: getActionNameByAnchor(nowTargetNode.type, item.targetAnchor) // 连接的action
283 })
284 }
285 temp.push(start)
286 return temp.flat(Infinity)
287 })
288 const uniqueArr = [] // 相同id 不同事件进行合并
289 result.flat(Infinity).forEach((tep) => {

Callers 1

getChildrenPropertyFunction · 0.70

Calls 5

findEdgesByIdFunction · 0.85
getSetNodePropertyFunction · 0.85
findNodeByIdFunction · 0.85
getActionNameByAnchorFunction · 0.85
targetNodeIsEndFunction · 0.85

Tested by

no test coverage detected