增加 Debug 启动开关,非0跳过登录直达主界面
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
<add key="CompressorDisplacementCc" value="35CC"/>
|
||||
<add key="FluidsPath" value="C:\Program Files (x86)\REFPROP\fluids"/>
|
||||
<add key="Cryogen" value="R134a"/>
|
||||
<add key="Debug" value="1"/>
|
||||
<add key="LocalDBPath" value="D:\MSDB\LocalDb\CapMachineDb"/>
|
||||
</appSettings>
|
||||
</configuration>
|
||||
@@ -268,9 +268,28 @@ namespace CapMachine.Wpf
|
||||
RegionManager.SetRegionManager(view, regionManager);
|
||||
RegionManager.UpdateRegions();
|
||||
|
||||
var configService = container.Resolve<ConfigService>();
|
||||
|
||||
//给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
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取调试模式配置。
|
||||
/// 非 0 表示调试模式(跳过登录),0 表示部署模式(需要登录)。
|
||||
/// </summary>
|
||||
/// <returns>是否调试模式。</returns>
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user