Baidu Inc. recorded its biggest revenue drop in more than two years after China’s economic malaise undermined its push into generative AI.