diff --git a/XplorePlane/App.xaml b/XplorePlane/App.xaml index dfa1cb0..bd56be9 100644 --- a/XplorePlane/App.xaml +++ b/XplorePlane/App.xaml @@ -1,7 +1,8 @@ + xmlns:converters="clr-namespace:XplorePlane.Converters" + ShutdownMode="OnMainWindowClose"> diff --git a/XplorePlane/App.xaml.cs b/XplorePlane/App.xaml.cs index 98ac0dc..992575a 100644 --- a/XplorePlane/App.xaml.cs +++ b/XplorePlane/App.xaml.cs @@ -349,6 +349,10 @@ namespace XplorePlane //} // ── 登录认证:在显示主窗口前弹出登录对话框 ── + // 临时切换 ShutdownMode,防止 LoginDialog 关闭时 WPF 自动退出应用 + var previousShutdownMode = Application.Current.ShutdownMode; + Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; + var loginViewModel = Container.Resolve(); var loginDialog = new LoginDialog(loginViewModel); var loginResult = loginDialog.ShowDialog(); @@ -364,6 +368,9 @@ namespace XplorePlane Log.Information("登录认证成功,角色: {Role}", Container.Resolve().CurrentRole); + // 恢复 ShutdownMode,让主窗口关闭时正常退出 + Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose; + var shell = Container.Resolve(); // 主窗体加载完成后再连接相机,确保所有模块和原生 DLL 已完成初始化