It's easy - plug it into the charger, and program the charger to come on for an hour or two once a week.
E cars end up in that state through neglect, not because there isn't a very easy means of preventing it.
It's not the main battery that's the problem. Most e cars have a second 12v battery, much like a normal car does, and that powers most functions other than the drive, and its that which goes flat. ICE cars suffer identically if they are not used or placed on charger.
The traction batter is fine, a different chemistry, and will hold its charge for months or even years, although its not recommended to do so frequently...which is where plugging it in and programming the charger comes in.
If it's the normal battery that is the issue using a trickle charging solar panel charger may be sufficient.