Thor's power level fluctuated continuously in Avengers: Infinity War, and it may in fact have been for a very good reason. The God of Thunder was coming from consecutive tragedies by the time Thanos appeared in the MCU. Coming off from the death of Odin and the destruction of Asgard in Thor: Ragnarok, Infinity War piled up on that by having Thor be quickly neutralized so he could then helplessly watch the death of half of his people - including Loki and Heimdall's deaths at the hands of the Mad Titan.
He was almost dead before the Guardians of the Galaxy found him floating in space, but during his trip to Nidevellir, he seemed to be in top shape again, as he's able to directly take on the energy of a full star. Thor held up long enough just for Eitri to forge the Stormbreaker, after which he was once again knocked out, but by the time he arrived in Wakanda, he appeared to be stronger than ever. These fluctuations were confusing for viewers, but looking more closely at his arc in Infinity War coupled with additional information from its writers, Christopher Markus and Stephen McFeely, there's an explanation for all this.
When the Infinity War writers were confronted with this question, they admitted that it's not something they specifically thought about while writing the movie. Nevertheless, they pointed out that while Thor is supposedly indestructible, he can also be drained of energy. He has just had tumultuous last several days for their explanation as to why the God of Thunder was so easily neutralized by Thanos and the Black Order. After his fight in Surtur at the beginning of Ragnarok, Thor was consecutively pitted against the rampaging Hulk and Hela. That no doubt drained him by itself, without even taking into account the mental stress brought about by the successive personal deaths he had to watch.
Aside from Markus and McFeely's explanation, there are other things to consider when tracking Thor's powers in Infinity War. After he survived the explosion of the Asgardian ship and was woken up by the Guardians of the Galaxy, he was quickly back on his feet. At this point, Thor already had his eyes set on getting the Stormbreaker; without missing a beat, he packed up essentials and left. At this point until taking on the full energy of a star, Thor was operating on adrenaline. Considering the extreme emotions of sadness for the many deaths he witnessed and anger directed toward Thanos, he was focused on the goal of exacting revenge, boosting his energy levels.
Thor's adrenaline could only do so much, however. Once enough Uru metal was melted for the Stormbreaker, he collapsed, and once again found himself almost dead. What brought him back to life and made him stronger than ever for his fight in Wakanda was the magical ax itself. Stormbreaker accelerated his self-healing ability, restoring his physical body back to its glory shape and making him more than ready for the all-out fight against the Black Order, Outriders, and eventually, Thanos at the end of Avengers: Infinity War.