After tossing for two nights, I finally solved this problem and entered the desktop.
The problem is as follows: I installed the ubuntu-gnome-shell package, and then the option to configure the display manager appears. There are gdm3 and lightdm. I randomly choose a gdm3, and it will not open after restarting.
Solution: Enter the command line ctrl + alt + f2/f3/f4/f5 and log in.
Run the command to reconfigure:
sudo dpkg-reconfigure lightdm
Then there is an option to configure the display manager, select lightdm, and restart it.
I've been stuck in this place for a long time entering the command line, and I can't get in. Later, I rolled the keyboard and got in.