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