设置界面优化

This commit is contained in:
hsc
2026-06-09 09:19:35 +08:00
parent bb4fe61ded
commit c01aa6e545
16 changed files with 196 additions and 59 deletions

View File

@@ -29,7 +29,7 @@ namespace MainModule.ViewModels
public ScopedContext _scopedContext { get; }
public StepRunning _stepRunning { get; }
public GlobalInfo _globalInfo { get; }
public SystemConfig _systemConfig { get; }
public SystemConfig _systemConfig { get; set; }
// 5 个子 ViewModel 全部从同一个 scope 解析,自动注入同一个 ScopedContext
public CommandTreeViewModel CommandTreeVM { get; }
@@ -50,7 +50,6 @@ namespace MainModule.ViewModels
// 在该作用域内解析 ScopedContext —— 当前作用域唯一
_scopedContext = _scope.Resolve<ScopedContext>();
_stepRunning = _scope.Resolve<StepRunning>();
_systemConfig=_scope.Resolve<SystemConfig>();
// 关键:从同一个 _scope 解析 5 个子 VMDI 会把同一个 ScopedContext 注入它们
CommandTreeVM = _scope.Resolve<CommandTreeViewModel>();
StepsManagerVM = _scope.Resolve<StepsManagerViewModel>();
@@ -108,6 +107,18 @@ namespace MainModule.ViewModels
_globalInfo.ContextDic.Add(TestStatus, _scopedContext);
_globalInfo.StepRunningDic.Add(TestStatus, _stepRunning);
_globalInfo.ScopeDic.Add(TestStatus, _scope);
_systemConfig = _scope.Resolve<SystemConfig>();
if (ConfigService.IsExit(TestStatus))
{
string filePath = System.IO.Path.Combine(_systemConfig.SystemPath, $"{TestStatus}.json");
if (System.IO.File.Exists(filePath))
{
string json = System.IO.File.ReadAllText(filePath);
// 🔥 关键:把 json 数据直接灌入当前实例,对象引用没有任何改变
Newtonsoft.Json.JsonConvert.PopulateObject(json, _systemConfig);
}
}
}
}