From 031fc34f125a4f35621e7231cbb0a698c0bf3964 Mon Sep 17 00:00:00 2001 From: SugarChes Date: Wed, 5 Aug 2026 17:27:02 +0800 Subject: [PATCH] fix_WPF_switch_user_main_loop_conflict --- 插件库/Lskj.Main/FrmSwap.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/插件库/Lskj.Main/FrmSwap.cs b/插件库/Lskj.Main/FrmSwap.cs index 54f41d5..9dddc6d 100644 --- a/插件库/Lskj.Main/FrmSwap.cs +++ b/插件库/Lskj.Main/FrmSwap.cs @@ -428,10 +428,19 @@ namespace Lskj.Main ERPInfo.Instance.UserId = userId; ERPInfo.Instance.UserName = userName; - this.Close(); IniHelper.Write("isRefresh", "1"); - Manager.ReStartMain(true); - //this.DialogResult = System.Windows.Forms.DialogResult.OK; + if (Manager.ExternalMainShell == null) + { + this.Close(); + Manager.ReStartMain(true); + } + else + { + // WPF 已接管主窗口生命周期:只返回切换成功, + // 由 WPF 在当前模态窗体关闭后重建主框架。 + this.DialogResult = System.Windows.Forms.DialogResult.OK; + this.Close(); + } break; case 1: // 密码不正确 MessageUtil.Show(ResourceKeys.NameOrPasswordError);