Greetings, robertsong.
I see that your iMac has slowed down since you upgraded to macOS Mojave. I'm happy to help.
How to reset the System Management Controller (SMC) on your Mac -- Reset the System Management Controller. Follow the steps under "How to reset the SMC on Mac desktop computers". Test the issue once you're back to the desktop.
Use safe mode to isolate issues with your Mac -- If resetting the SMC didn't resolve the issue, restart your Mac in safe mode and test how it responds. Afterwards, reboot normally and log into your own user account. Remember this when booting in safe mode: Graphics performance limited in macOS Recovery, safe mode, or Guest User mode
How to test an issue in another user account on your Mac -- If the issue is also happening in safe mode, use this article to create and test a new user account. This will demonstrate if the issue is isolated to your account, or if its system wide.
Let me know how that goes, and take care!