You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
856 B
C#
30 lines
856 B
C#
using System.Text.Json;
|
|
using RoBot.Start.ConstValue;
|
|
using RoBot.Start.Dto.ConfigDto;
|
|
|
|
namespace RoBot.Start.RoBotConfig
|
|
{
|
|
public class RoBotsConfig
|
|
{
|
|
/// <summary>
|
|
/// 获取配置信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static async Task<ConfigSetting> GetConfig()
|
|
{
|
|
ConfigSetting config = new();
|
|
if (File.Exists(Consts.Config))
|
|
{
|
|
var config_json = await File.ReadAllTextAsync(Consts.Config);
|
|
config = JsonSerializer.Deserialize<ConfigSetting>(config_json) ?? config;
|
|
}
|
|
else
|
|
{
|
|
var config_json = JsonSerializer.Serialize(config);
|
|
await File.WriteAllTextAsync(Consts.Config, config_json);
|
|
}
|
|
return config;
|
|
}
|
|
}
|
|
}
|