默认文件路径保存
This commit is contained in:
@@ -15,8 +15,13 @@ namespace SettingModule.ViewModels
|
||||
{
|
||||
|
||||
#region 属性
|
||||
private SystemConfig _systemConfig;
|
||||
public SystemConfig SystemConfig
|
||||
{
|
||||
get => _systemConfig;
|
||||
set => SetProperty(ref _systemConfig, value);
|
||||
}
|
||||
public bool KeepAlive => true;
|
||||
|
||||
public string TestStatus
|
||||
{
|
||||
get => _testStatus;
|
||||
@@ -61,7 +66,7 @@ namespace SettingModule.ViewModels
|
||||
#endregion
|
||||
#region 私有字段
|
||||
private IScopedProvider _scope;
|
||||
private SystemConfig _systemConfig;
|
||||
|
||||
private ScopedContext _scopedContext { get; set; }
|
||||
private GlobalInfo _globalInfo { get; }
|
||||
private bool IsInitiated = false;
|
||||
@@ -110,20 +115,20 @@ namespace SettingModule.ViewModels
|
||||
/// <summary>保存当前 SystemConfig 到 SystemPath 下,文件名为 {Title}.json。</summary>
|
||||
private void OnSave()
|
||||
{
|
||||
if (_systemConfig == null)
|
||||
if (SystemConfig == null)
|
||||
{
|
||||
StatusMessage = "无可保存的配置";
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(_systemConfig.Title))
|
||||
if (string.IsNullOrWhiteSpace(SystemConfig.Title))
|
||||
{
|
||||
StatusMessage = "保存失败:标题(Title)不能为空";
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigService.Save(_systemConfig);
|
||||
StatusMessage = $"已保存配置 [{_systemConfig.Title}.json] 至 {_systemConfig.SystemPath}({DateTime.Now:HH:mm:ss})";
|
||||
ConfigService.Save(SystemConfig);
|
||||
StatusMessage = $"已保存配置 [{SystemConfig.Title}.json] 至 {SystemConfig.SystemPath}({DateTime.Now:HH:mm:ss})";
|
||||
}
|
||||
|
||||
/// <summary>重置当前选中设备的配置(占位)。</summary>
|
||||
@@ -164,7 +169,7 @@ namespace SettingModule.ViewModels
|
||||
var p = new DialogParameters
|
||||
{
|
||||
{ "Device", SelectedDevice },
|
||||
{ "SystemConfig", _systemConfig }
|
||||
{ "SystemConfig", SystemConfig }
|
||||
};
|
||||
|
||||
_dialogService.ShowDialog(dialogName, p, r =>
|
||||
@@ -186,12 +191,12 @@ namespace SettingModule.ViewModels
|
||||
TestStatus = navigationContext.Parameters.GetValue<string>("Name");
|
||||
_scope = _globalInfo.ScopeDic[TestStatus];
|
||||
_scopedContext = _globalInfo.ContextDic[TestStatus];
|
||||
_systemConfig = _scope.Resolve<SystemConfig>();
|
||||
SystemConfig = _scope.Resolve<SystemConfig>();
|
||||
if (DeviceList != null && DeviceList.Count > 0)
|
||||
{
|
||||
SelectedDevice = DeviceList[0];
|
||||
}
|
||||
DeviceList = _systemConfig.DeviceList;
|
||||
DeviceList = SystemConfig.DeviceList;
|
||||
IsInitiated = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user