2026-04-10 22:06:39 +08:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
2026-04-10 22:38:28 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 动态配置模块。
|
|
|
|
|
/// </summary>
|
2026-04-10 22:06:39 +08:00
|
|
|
public sealed class BriskConfigModule
|
|
|
|
|
: BriskModuleBase
|
|
|
|
|
{
|
2026-04-10 22:38:28 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 获取当前客户端命中的动态配置。
|
|
|
|
|
/// </summary>
|
2026-04-10 22:06:39 +08:00
|
|
|
public async Task<BriskConfigCurrent> GetCurrentAsync()
|
|
|
|
|
{
|
|
|
|
|
return await ExecutePublicAsync(async context =>
|
|
|
|
|
{
|
|
|
|
|
var data = await context.HttpClient.GetDataAsync("/config/current", CreateQuery(context), false);
|
|
|
|
|
return BriskModelMapper.ToConfigCurrent(data);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-10 22:38:28 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 刷新并重新获取动态配置。
|
|
|
|
|
/// </summary>
|
2026-04-10 22:06:39 +08:00
|
|
|
public Task<BriskConfigCurrent> RefreshAsync()
|
|
|
|
|
{
|
|
|
|
|
return GetCurrentAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Dictionary<string, string> CreateQuery(BriskContext context)
|
|
|
|
|
{
|
|
|
|
|
return new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "game_key", context.Options.GameKey },
|
|
|
|
|
{ "client_version", context.Options.ClientVersion }
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|