4. The difference between the maximum and minimum values of the function $f(x)=\sin 2 x+\mathrm{e}^{|\sin x+\cos x|}$ is

保留了原文的换行和格式。
4. $1+\mathrm{e}^{\sqrt{2}}$ Detailed: $f(x)=\sin 2 x+\mathrm{e}^{|\sin x+\cos x|}=\sin 2 x+\mathrm{e}^{\sqrt{2}}\left|\sin \left(x+\frac{\pi}{4}\right)\right|$, thus when $x=\frac{\pi}{4}$, the maximum value $1+\mathrm{e}^{\sqrt{2}}$ is obtained.
When $x=-\frac{\pi}{4}$, the minimum value 0 is obtained, thus the difference between the maximum and minimum values is $1+\mathrm{e}^{\sqrt{2}}$.