Multifunctionalizing electrolytes in situ for lithium metal batteries