Printed circuit boards (PCBs) are a critical component of modern electronic equipment, performing a crucial role in the electronic information industry chain. However, accurate detection of PCB defects can be challenging. To address this problem, this paper proposes an enhanced detection method based on an improved YOLOv7 network. First, the SwinV2_TDD module is proposed, which adds a convolutional layer to extract the local features of the PCB. Then, the Magnification Factor Shuffle Attention (MFSA) mechanism is introduced, which adds a convolutional layer to each branch of the Shuffle Attention (SA) to expand its depth and enhance the adaptability of the attention mechanism. The SwinV2_TDD module and MFSA mechanism are integrated into the YOLOv7 network, replacing some ELAN modules and changing the activation function to Mish. The evaluation indexes used are Precision (P), Recall (R), and mean Average Precision (mAP). Experimental results show that the enhanced method achieves an AP of 98.74%, indicating a significant improvement in PCB defect detection performance.