Synthesis and Structure–Property Relationships of Polyimide Covalent Organic Frameworks for Carbon Dioxide Capture and (Aqueous) Sodium-Ion Batteries