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(); + } } //瀹瑰櫒瑙f瀽椤哄簭涓嶈鏀瑰彉锛侊紒锛 _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; - } - } - } - + /// /// 淇濆瓨鎸囧畾鐨勯厤缃疄渚 ///