修复头像重叠问题
This commit is contained in:
		
							parent
							
								
									1688d8b200
								
							
						
					
					
						commit
						ddcba3b96e
					
				| 
						 | 
					@ -171,11 +171,28 @@ onMounted(() => {
 | 
				
			||||||
  // 5. 节点分布在各自combo圆内
 | 
					  // 5. 节点分布在各自combo圆内
 | 
				
			||||||
  nodes.forEach(node => {
 | 
					  nodes.forEach(node => {
 | 
				
			||||||
    const combo = combos.find(c => c.id === node.comboId);
 | 
					    const combo = combos.find(c => c.id === node.comboId);
 | 
				
			||||||
    // 随机分布在combo圆内
 | 
					    let valid = false;
 | 
				
			||||||
    const angle = Math.random() * 2 * Math.PI;
 | 
					    let tryCount = 0;
 | 
				
			||||||
    const radius = Math.random() * (combo.r - nodeSize / 2);
 | 
					    let x, y;
 | 
				
			||||||
    node.x = combo.x + Math.cos(angle) * radius;
 | 
					    const placed = nodes.filter(n => n.comboId === node.comboId && n !== node);
 | 
				
			||||||
    node.y = combo.y + Math.sin(angle) * radius;
 | 
					    while (!valid && tryCount < 100) {
 | 
				
			||||||
 | 
					      const angle = Math.random() * 2 * Math.PI;
 | 
				
			||||||
 | 
					      const radius = Math.random() * (combo.r - nodeSize / 2);
 | 
				
			||||||
 | 
					      x = combo.x + Math.cos(angle) * radius;
 | 
				
			||||||
 | 
					      y = combo.y + Math.sin(angle) * radius;
 | 
				
			||||||
 | 
					      valid = true;
 | 
				
			||||||
 | 
					      for (const other of placed) {
 | 
				
			||||||
 | 
					        const dx = x - other.x;
 | 
				
			||||||
 | 
					        const dy = y - other.y;
 | 
				
			||||||
 | 
					        if (Math.sqrt(dx * dx + dy * dy) < nodeSize) {
 | 
				
			||||||
 | 
					          valid = false;
 | 
				
			||||||
 | 
					          break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      tryCount++;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    node.x = x;
 | 
				
			||||||
 | 
					    node.y = y;
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // 6. 用 layout: null,G6 不再自动布局
 | 
					  // 6. 用 layout: null,G6 不再自动布局
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user