diff --git a/ADP/ViewModels/ShellViewModel.cs b/ADP/ViewModels/ShellViewModel.cs index a17894f..c028ba2 100644 --- a/ADP/ViewModels/ShellViewModel.cs +++ b/ADP/ViewModels/ShellViewModel.cs @@ -84,7 +84,8 @@ namespace ADP.ViewModels _globalInfo.ContextDic.TryGetValue(_globalInfo.CurrentScope, out var ctx) ? ctx : null; private StepRunning? CurrentRunner => _globalInfo.StepRunningDic.TryGetValue(_globalInfo.CurrentScope, out var runner) ? runner : null; - + private SystemConfig? CurrentConfig => + _globalInfo.ConfigDic.TryGetValue(_globalInfo.CurrentScope, out var config) ? config : null; public string RunState { get => CurrentContext?.RunState ?? "运行"; @@ -179,7 +180,7 @@ namespace ADP.ViewModels Application.Current.MainWindow.Show(); _regionManager.RequestNavigate("ShellViewManager", "MainView"); }); - + _eventAggregator.GetEvent().Subscribe(UpdateRunIcon); _globalInfo.ScopeChanged += (s, e) => @@ -459,6 +460,7 @@ namespace ADP.ViewModels private void SetDefault() { + if (CurrentConfig == null) return; // 💡 1. 抓取触发瞬间的 Scope 与 Context 快照 string runningScope = _globalInfo.CurrentScope; ScopedContext? targetContext = CurrentContext; @@ -467,8 +469,8 @@ namespace ADP.ViewModels if (targetContext.CurrentFilePath != null) { - //SystemConfig.DefaultProgramFilePath = targetContext.CurrentFilePath; - //ConfigService.Save(); + CurrentConfig.DefaultProgramFilePath = targetContext.CurrentFilePath; + ConfigService.Save(CurrentConfig); LoggerHelper.SuccessWithNotify($"工位 [{runningScope}] 已成功将当前程序设为默认启动程序"); } } diff --git a/ADP/Views/ShellView.xaml b/ADP/Views/ShellView.xaml index c41b7b3..f1049e0 100644 --- a/ADP/Views/ShellView.xaml +++ b/ADP/Views/ShellView.xaml @@ -60,11 +60,11 @@ CommandParameter="{Binding Content, RelativeSource={RelativeSource Self}}" Style="{StaticResource MaterialDesignFlatButton}" Margin="8" /> -