Through experiments, I found that the bed can only be used in the main world. Therefore, I set the only dimension that I need to sleep on as the main world, and then generate my dimension that needs to sleep through the night by exporting the world settings and quoting the custom generation rules in the data package.