From 4be032918d92ba155fb63d9d0a2eaa98b2995040 Mon Sep 17 00:00:00 2001 From: "zhengxuan.zhang" Date: Mon, 1 Jun 2026 17:32:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XplorePlane/App.xaml | 3 ++- XplorePlane/App.xaml.cs | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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 已完成初始化