Hydrogen peroxide (H2O2) is a crucial energy carrier with growing significance in sustainable energy systems. Covalent organic frameworks (COFs) have recently emerged as promising materials for efficient H2O2 photosynthesis, while transition-metal complexes are recognized for their efficacy as molecular photocatalysts in H2O2 production. This study introduces a novel π-π interaction strategy to immobilize ruthenium complexes into COFs, using DaTp COF as a model system. This approach significantly enhances the photocatalytic activity for H2O2 production, achieving an initial rate of 3276 μmol g-1 h-1 without using scavengers under visible-light irradiation (λ > 420 nm). Notably, incorporating ruthenium complexes optimizes the oxygen reduction reaction pathways, shifting from a less efficient four-electron process to a more efficient two-electron process. Density functional theory calculations further reveal that ruthenium complexes not only broaden the light absorption spectrum of the COF but also increase water affinity, directly contributing to H2O2 generation. These findings offer a strategic framework for designing and enhancing COFs in H2O2 photosynthesis applications.