Thermodynamic geometry of black holes enclosed by a cavity in extended phase space