Osmotic energy, abundant in seawater and high-salinity industrial wastewater, is a highly promising renewable "blue energy". However, practical osmotic energy recovery has been hindered by challenges such as membrane fouling caused by complex aqueous environment. In this study, we developed light-activated heterogeneous nanochannel membranes by continuous stacking two-dimensional semiconducting and metal-like nanosheets, significantly enhancing both ion transport efficiency and stability in complex, real-world aqueous environments. By leveraging light to create temperature gradients and built-in electric fields, solar energy was efficiently converted into a powerful driving force, markedly boosting ion transport efficiency. More importantly, the membrane continuously generated free radicals via photoexcitation and storage, effectively mitigating membrane fouling-even in low-light and nighttime conditions. As a result, while power density initially decreased by maximum of 87 % within 12 h due to organic contamination, it not only recovered to its original level under light exposure but also achieved a twofold increase, demonstrating robust energy recovery performance. Over 60 days of testing in Bohai Sea water, coal chemical wastewater from Shaanxi, and Da Qaidam Salt Lake brine, the system maintained stable power densities of up to 5.43 W/m