Facile synthesis of intelligent nanocomposites as encapsulation for materials protection