I’ve followed the advice of not washing my ebike frame, not even with a garden hose, as much for preserving the bearings as the electrics
After a ride let mud dry then brush it off and spot clean with a wet cloth
I’ve been using Dielectric Grease to protect electrical points
My understanding is that using a small amount still allows the metal to metal contact for the electrical connection, but the dielectric grease sits around these areas which physically prevents water and grime getting near the actual contacts
https://www.ebay.co.uk/itm/355033744279
As my battery is easily removable for charging, I’ve mostly taped the edges of my frames charge port, as I rarely use it, but this may not be practical for you if you are using the charge port for every ride