Innovative Inverse-Design Approach for On-Chip Computational Spectrometers: Enhanced Performance and Reliability