Vapour-assisted multi-functional perovskite thin films for solar cells and photodetectors