Crown ethers, known for their efficacy as metal ion traps, have garnered significant interest in optoelectronic applications due to their unique cavity structure and special binding ability with metals. Herein, we systematically designed and investigated the second-order nonlinear optical (NLO) properties of an intriguing compound, 18-crown-6 derivative appended with 25-oxasmaragdyrins (Cr-Prs), achieved through the incorporation of diverse metal ions into the crown ether ring. Significantly, the βtot values of compounds with alkaline earth metal ions (Mg2+, Ca2+) are greater than those compounds with alkali metal ions (Na+, K+). Interestingly, the Hg2+@Cr-Prs compound exhibits a tremendous second-order NLO property with the βtot value of 5.34 × 105 au. Further insights into substantial βtot values across all compounds were provided through a comprehensive analysis of the transition energies, the molecular orbitals, and the absorption spectra of the main excited states. The calculation results conclude that the second-order NLO properties of Cr-Prs can be modulated by incorporating metal ions into the crown ether ring. Crown ether emerges as a facilitator in detecting and identifying Hg2+ ions, serving as an effective NLO-based ion detector. These findings not only broaden the scope of cation detection and efficiency but also present innovative applications in analytical and optoelectronic research, encapsulating the essence of our study within a concise framework.