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

Function onSelectNode

src/pages/Workspace/BluePrint.jsx:398–427  ·  view source on GitHub ↗
(id)

Source from the content-addressed store, hash-verified

396 }
397
398 const onSelectNode = (id) => {
399 // 点击判断条件
400 const saveNodeData = graph.save(); // 保存当前蓝图编辑器数据
401 const clickNode = findNodeById(saveNodeData.nodes, id)
402 let { type } = clickNode
403 if (type === 'element' || type === 'interActive') {
404 type = 'component'
405 }
406
407 const judgeIndex = allNodeConfig[type].findIndex(item => { return item.id === id })
408 if (judgeIndex === -1) {
409 // 不存在则新增
410 const config = getNodeProperty(type, id, clickNode.label)
411 setNowJudge(config)
412 allNodeConfig[type].push(config)
413 } else {
414 // 存在则取出来直接用
415 const nowProperty = allNodeConfig[type][judgeIndex].property
416 if (type === 'component') {
417 const nowNodeTargetEdges = findEdgesById(saveNodeData.edges, id)
418 nowNodeTargetEdges.forEach(item => {
419 const nowNodeActionName = getActionNameByAnchor(clickNode.type, item.targetAnchor)
420 allNodeConfig[type][judgeIndex].property = nowProperty.filter(v => { return v.actionName === nowNodeActionName }) // 过滤掉没有选中的actionName属性
421 })
422 }
423
424 setNowJudge(allNodeConfig[type][judgeIndex])
425 }
426 setDetailsPanelVisible(true)
427 }
428 const closeDetailPanel = () => {
429 setDetailsPanelVisible(false)
430 }

Callers

nothing calls this directly

Calls 4

findNodeByIdFunction · 0.85
getNodePropertyFunction · 0.85
findEdgesByIdFunction · 0.85
getActionNameByAnchorFunction · 0.85

Tested by

no test coverage detected