Two-dimensional transition-metal-containing polyphthalocyanine conjugated porous frameworks are synthesized, and transition-metal (TM) ions ranging from Fe, Co, Ni, Cu to In are chosen to combine in phthalocyanine centers to tune their delocalized electronic structure. The fully closed planar delocalized π-conjugated frameworks exhibit efficient nonlinear optical absorption and excellent optical limiting performance under ns pulsed laser. The metal ion (Co, Ni) with ferromagnetism in phthalocyanine center manifests its contribution in enhanced nonlinear optical response through resonance enhancement of the nonlinear excited-state absorption.