重构middle-wares和hooks