From 0e9f65ea2103648b7a6fa1ccc3836ca14535042d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chsc=E2=80=9D?= <“huangsucan@kaiyili-lab.com”> Date: Thu, 30 Jul 2026 13:24:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MainModule/MainModule.cs | 12 ++--- .../ViewModels/AutomatedTestingViewModel.cs | 4 ++ UIShare/GlobalVariable/ConfigService.cs | 48 +------------------ 3 files changed, 11 insertions(+), 53 deletions(-) diff --git a/MainModule/MainModule.cs b/MainModule/MainModule.cs index 8bb3055..69e18b6 100644 --- a/MainModule/MainModule.cs +++ b/MainModule/MainModule.cs @@ -17,14 +17,14 @@ namespace MainModule regionManager.RegisterViewWithRegion("ShellViewManager", typeof(MainView)); // 2. 3 ֱ̨ܷעͼ - // "̨ 1" Tab ʱͻʾ AutomatedTestingView - regionManager.RegisterViewWithRegion("TestCell1", typeof(AutomatedTestingView)); + // "̨ 1" Tab ʱͻʾ ProtocolStartView + regionManager.RegisterViewWithRegion("TestCell1", typeof(ProtocolStartView)); - // "̨ 2" Tab ʱͻʾ AutomatedTestingView - regionManager.RegisterViewWithRegion("TestCell2", typeof(AutomatedTestingView)); + // "̨ 2" Tab ʱͻʾ ProtocolStartView + regionManager.RegisterViewWithRegion("TestCell2", typeof(ProtocolStartView)); - // "̨ 3" Tab ʱͻʾ AutomatedTestingView - regionManager.RegisterViewWithRegion("TestCell3", typeof(AutomatedTestingView)); + // "̨ 3" Tab ʱͻʾ ProtocolStartView + regionManager.RegisterViewWithRegion("TestCell3", typeof(ProtocolStartView)); } public void RegisterTypes(IContainerRegistry containerRegistry) diff --git a/MainModule/ViewModels/AutomatedTestingViewModel.cs b/MainModule/ViewModels/AutomatedTestingViewModel.cs index 21a64bb..083fa23 100644 --- a/MainModule/ViewModels/AutomatedTestingViewModel.cs +++ b/MainModule/ViewModels/AutomatedTestingViewModel.cs @@ -69,6 +69,10 @@ namespace MainModule.ViewModels string json = System.IO.File.ReadAllText(filePath); Newtonsoft.Json.JsonConvert.PopulateObject(json, _systemConfig); } + else + { + _systemConfig = new SystemConfig(); + } } //容器解析顺序不要改变!!! _scopedContext = _scope.Resolve(); diff --git a/UIShare/GlobalVariable/ConfigService.cs b/UIShare/GlobalVariable/ConfigService.cs index 83a41aa..1176ebd 100644 --- a/UIShare/GlobalVariable/ConfigService.cs +++ b/UIShare/GlobalVariable/ConfigService.cs @@ -29,53 +29,7 @@ namespace UIShare.GlobalVariable } return true; } - /// - /// 根据标题(格子标识)加载独立的配置文件 - /// - public static SystemConfig Load(string title) - { - if (string.IsNullOrEmpty(title)) - { - throw new ArgumentException("配置标题不能为空", nameof(title)); - } - - // 临时实例化一个对象以获取默认的 SystemPath - var dummy = new SystemConfig(); - string configPath = Path.Combine(dummy.SystemPath, $"{title}.json"); - - if (!File.Exists(configPath)) - { - // 如果不存在,创建一个带 Title 的默认配置并保存 - var defaultConfig = new SystemConfig { Title = title }; - EnsureDefaultCanDevice(defaultConfig); - Save(defaultConfig); - return defaultConfig; - } - - lock (_fileLock) - { - try - { - string json = File.ReadAllText(configPath); - var config = JsonConvert.DeserializeObject(json, new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.All - }); - - config ??= new SystemConfig { Title = title }; - EnsureDefaultCanDevice(config); - return config; - } - catch (Exception ex) - { - LoggerHelper.ErrorWithNotify(title, $"格子 [{title}] 配置加载失败: {ex.Message}"); - var fallback = new SystemConfig { Title = title }; - EnsureDefaultCanDevice(fallback); - return fallback; - } - } - } - + /// /// 保存指定的配置实例 ///