From a59423a8c980b00c69360e12613af8f99e9e54c9 Mon Sep 17 00:00:00 2001 From: Tyrone CT Date: Mon, 30 Mar 2026 14:46:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20Debug=20=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E5=BC=80=E5=85=B3=EF=BC=8C=E9=9D=9E0=E8=B7=B3=E8=BF=87?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E7=9B=B4=E8=BE=BE=E4=B8=BB=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CapMachine.Wpf/App.config | 1 + CapMachine.Wpf/App.xaml.cs | 44 +++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/CapMachine.Wpf/App.config b/CapMachine.Wpf/App.config index 9a5c2da..5e08d11 100644 --- a/CapMachine.Wpf/App.config +++ b/CapMachine.Wpf/App.config @@ -10,6 +10,7 @@ + \ No newline at end of file diff --git a/CapMachine.Wpf/App.xaml.cs b/CapMachine.Wpf/App.xaml.cs index 77f3a48..11863b6 100644 --- a/CapMachine.Wpf/App.xaml.cs +++ b/CapMachine.Wpf/App.xaml.cs @@ -268,9 +268,28 @@ namespace CapMachine.Wpf RegionManager.SetRegionManager(view, regionManager); RegionManager.UpdateRegions(); + var configService = container.Resolve(); + //给MainView的MainViewFooterContentRegion区域设置FooterView具体的信息 regionManager.RequestNavigate("MainViewFooterContentRegion", nameof(FooterView)); - regionManager.RequestNavigate("MainViewContentRegion", nameof(UserManageView)); + if (IsDebugMode()) + { + configService.IsUserLoggedIn = true; + if (configService.CurUserDto != null) + { + configService.CurUserDto.Name = "DebugUser"; + configService.CurUserDto.Level = "管理员"; + configService.CurUserDto.IsEnable = true; + configService.CurUserDto.Password = string.Empty; + } + + regionManager.RequestNavigate("MainViewContentRegion", nameof(MonitorView)); + } + else + { + configService.IsUserLoggedIn = false; + regionManager.RequestNavigate("MainViewContentRegion", nameof(UserManageView)); + } //调用首页的INavigationAware 接口做一个初始化操作 if (view.DataContext is INavigationAware navigationAware) @@ -444,6 +463,29 @@ namespace CapMachine.Wpf } + /// + /// 读取调试模式配置。 + /// 非 0 表示调试模式(跳过登录),0 表示部署模式(需要登录)。 + /// + /// 是否调试模式。 + private bool IsDebugMode() + { + try + { + var debugValue = ConfigHelper.GetValue("Debug"); + if (int.TryParse(debugValue, out var debugFlag)) + { + return debugFlag != 0; + } + + return false; + } + catch + { + return false; + } + } + #endregion