mirror of
https://github.com/denglihong2007/CRSim
synced 2026-08-10 11:36:07 +08:00
feat(settings): 设置改为注册表存储
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
using CRSim.Core.Abstractions;
|
||||
using CRSim.Core.Models;
|
||||
using CRSim.Core.Utils;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace CRSim.Core.Services
|
||||
@@ -24,11 +22,15 @@ namespace CRSim.Core.Services
|
||||
|
||||
_settings.ApiName = _settings.Api.Name;
|
||||
|
||||
var options = new JsonSerializerOptions { WriteIndented = true };
|
||||
string jsonString = JsonSerializer.Serialize(_settings, options);
|
||||
File.WriteAllText(_settingsFilePath, jsonString);
|
||||
}
|
||||
|
||||
private readonly JsonSerializerOptions options = new()
|
||||
{
|
||||
WriteIndented = true,
|
||||
};
|
||||
|
||||
public void LoadSettings()
|
||||
{
|
||||
try
|
||||
@@ -47,7 +49,6 @@ namespace CRSim.Core.Services
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
// Handle the case where the json is corrupted, load default settings
|
||||
_settings = new Settings();
|
||||
SaveSettings();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Version>3.1.4.1</Version>
|
||||
<Version>3.1.4.0</Version>
|
||||
<Authors>电排骨</Authors>
|
||||
<RepositoryUrl>https://github.com/denglihong2007/CRSim</RepositoryUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
Reference in New Issue
Block a user