Enhanced high-gain harmonic generation for x-ray free-electron laser