mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix #823
This commit is contained in:
@@ -9,7 +9,7 @@ using Snap.Hutao.Model.Metadata.Avatar;
|
||||
using Snap.Hutao.Model.Metadata.Weapon;
|
||||
using Snap.Hutao.Service.Metadata;
|
||||
using Snap.Hutao.ViewModel.GachaLog;
|
||||
using Snap.Hutao.Web.Hutao;
|
||||
using Snap.Hutao.Web.Hutao.GachaLog;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Snap.Hutao.Service.GachaLog.Factory;
|
||||
@@ -28,7 +28,7 @@ internal sealed partial class GachaStatisticsFactory : IGachaStatisticsFactory
|
||||
private readonly AppOptions options;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async ValueTask<GachaStatistics> CreateAsync(List<GachaItem> items, GachaLogServiceMetadataContext context)
|
||||
public async ValueTask<GachaStatistics> CreateAsync(List<Model.Entity.GachaItem> items, GachaLogServiceMetadataContext context)
|
||||
{
|
||||
await taskContext.SwitchToBackgroundAsync();
|
||||
List<GachaEvent> gachaEvents = await metadataService.GetGachaEventsAsync().ConfigureAwait(false);
|
||||
@@ -40,7 +40,7 @@ internal sealed partial class GachaStatisticsFactory : IGachaStatisticsFactory
|
||||
private static GachaStatistics CreateCore(
|
||||
ITaskContext taskContext,
|
||||
HomaGachaLogClient gachaLogClient,
|
||||
List<GachaItem> items,
|
||||
List<Model.Entity.GachaItem> items,
|
||||
List<HistoryWishBuilder> historyWishBuilders,
|
||||
in GachaLogServiceMetadataContext context,
|
||||
bool isEmptyHistoryWishVisible)
|
||||
@@ -62,7 +62,7 @@ internal sealed partial class GachaStatisticsFactory : IGachaStatisticsFactory
|
||||
|
||||
// Items are ordered by precise time, first is oldest
|
||||
// 'ref' is not allowed here because we have lambda below
|
||||
foreach (GachaItem item in CollectionsMarshal.AsSpan(items))
|
||||
foreach (Model.Entity.GachaItem item in CollectionsMarshal.AsSpan(items))
|
||||
{
|
||||
// Find target history wish to operate.
|
||||
HistoryWishBuilder? targetHistoryWishBuilder = historyWishBuilders
|
||||
|
||||
@@ -8,7 +8,7 @@ using Snap.Hutao.Model.Metadata.Weapon;
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
using Snap.Hutao.Service.Metadata;
|
||||
using Snap.Hutao.ViewModel.Complex;
|
||||
using Snap.Hutao.Web.Hutao.Model;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
namespace Snap.Hutao.Service.Hutao;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using Snap.Hutao.Core.Database;
|
||||
using Snap.Hutao.Model.Entity;
|
||||
using Snap.Hutao.Model.Entity.Database;
|
||||
using Snap.Hutao.Web.Hutao;
|
||||
using Snap.Hutao.Web.Hutao.Model;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
using Snap.Hutao.Web.Response;
|
||||
|
||||
namespace Snap.Hutao.Service.Hutao;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Snap.Hutao.Web.Hutao.Model;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Snap.Hutao.Service.Hutao;
|
||||
@@ -14,6 +14,7 @@ namespace Snap.Hutao.Service.Hutao;
|
||||
[Injection(InjectAs.Singleton)]
|
||||
internal sealed class HutaoUserOptions : ObservableObject, IOptions<HutaoUserOptions>
|
||||
{
|
||||
private readonly TaskCompletionSource initializedTaskCompletionSource = new();
|
||||
private string? userName = SH.ViewServiceHutaoUserLoginOrRegisterHint;
|
||||
private string? token;
|
||||
private bool isLoggedIn;
|
||||
@@ -31,11 +32,6 @@ internal sealed class HutaoUserOptions : ObservableObject, IOptions<HutaoUserOpt
|
||||
/// </summary>
|
||||
public string? ActualUserName { get => IsLoggedIn ? UserName : null; }
|
||||
|
||||
/// <summary>
|
||||
/// 访问令牌
|
||||
/// </summary>
|
||||
public string? Token { get => token; set => SetProperty(ref token, value); }
|
||||
|
||||
/// <summary>
|
||||
/// 是否已登录
|
||||
/// </summary>
|
||||
@@ -67,8 +63,9 @@ internal sealed class HutaoUserOptions : ObservableObject, IOptions<HutaoUserOpt
|
||||
public void LoginSucceed(string userName, string? token)
|
||||
{
|
||||
UserName = userName;
|
||||
Token = token;
|
||||
this.token = token;
|
||||
IsLoggedIn = true;
|
||||
initializedTaskCompletionSource.TrySetResult();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -77,6 +74,12 @@ internal sealed class HutaoUserOptions : ObservableObject, IOptions<HutaoUserOpt
|
||||
public void LoginFailed()
|
||||
{
|
||||
UserName = SH.ViewServiceHutaoUserLoginFailHint;
|
||||
initializedTaskCompletionSource.TrySetResult();
|
||||
}
|
||||
|
||||
public void SkipLogin()
|
||||
{
|
||||
initializedTaskCompletionSource.TrySetResult();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -89,4 +92,10 @@ internal sealed class HutaoUserOptions : ObservableObject, IOptions<HutaoUserOpt
|
||||
GachaLogExpireAt = Regex.Unescape(SH.ServiceHutaoUserGachaLogExpiredAt).Format(userInfo.GachaLogExpireAt);
|
||||
IsCloudServiceAllowed = IsLicensedDeveloper || userInfo.GachaLogExpireAt > DateTimeOffset.Now;
|
||||
}
|
||||
|
||||
public async ValueTask<string?> GetTokenAsync()
|
||||
{
|
||||
await initializedTaskCompletionSource.Task.ConfigureAwait(false);
|
||||
return token;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using Snap.Hutao.Core.Setting;
|
||||
using Snap.Hutao.Web.Hutao;
|
||||
using Snap.Hutao.Web.Hutao.Model;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
namespace Snap.Hutao.Service.Hutao;
|
||||
|
||||
@@ -35,7 +35,11 @@ internal sealed partial class HutaoUserService : IHutaoUserService, IHutaoUserSe
|
||||
string userName = LocalSetting.Get(SettingKeys.PassportUserName, string.Empty);
|
||||
string passport = LocalSetting.Get(SettingKeys.PassportPassword, string.Empty);
|
||||
|
||||
if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(passport))
|
||||
if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(passport))
|
||||
{
|
||||
options.SkipLogin();
|
||||
}
|
||||
else
|
||||
{
|
||||
Web.Response.Response<string> response = await passportClient.LoginAsync(userName, passport, token).ConfigureAwait(false);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
using Snap.Hutao.Model.Binding.Hutao;
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
using Snap.Hutao.ViewModel.Complex;
|
||||
using Snap.Hutao.Web.Hutao.Model;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
namespace Snap.Hutao.Service.Hutao;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Web.Hutao.Model;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
namespace Snap.Hutao.Service.Hutao;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ using Snap.Hutao.Core.ExceptionService;
|
||||
using Snap.Hutao.Model.Entity;
|
||||
using Snap.Hutao.Model.Entity.Database;
|
||||
using Snap.Hutao.Web.Hutao;
|
||||
using Snap.Hutao.Web.Hutao.Model;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
using Snap.Hutao.Web.Response;
|
||||
|
||||
namespace Snap.Hutao.Service.Hutao;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using Snap.Hutao.Model.Binding.Hutao;
|
||||
using Snap.Hutao.Service.Hutao;
|
||||
using Snap.Hutao.Web.Hutao.Model;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
namespace Snap.Hutao.ViewModel.Complex;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using Snap.Hutao.Model.Metadata.Converter;
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
using Snap.Hutao.Web.Hutao.Model;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using Snap.Hutao.Model.Metadata.Avatar;
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
using Snap.Hutao.Web.Hutao.Model;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Snap.Hutao.ViewModel.Complex;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using Snap.Hutao.Model.Metadata.Avatar;
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
using Snap.Hutao.Web.Hutao.Model;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
namespace Snap.Hutao.ViewModel.Complex;
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ using Snap.Hutao.Service.SpiralAbyss;
|
||||
using Snap.Hutao.Service.User;
|
||||
using Snap.Hutao.ViewModel.User;
|
||||
using Snap.Hutao.Web.Hutao;
|
||||
using Snap.Hutao.Web.Hutao.Model.Post;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss.Post;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Snap.Hutao.ViewModel.SpiralAbyss;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
using Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient;
|
||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord;
|
||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.Verification;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace Snap.Hutao.Web.Geetest;
|
||||
|
||||
@@ -5,6 +5,7 @@ using Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient;
|
||||
using Snap.Hutao.Model.Entity;
|
||||
using Snap.Hutao.Web.Hoyolab.Annotation;
|
||||
using Snap.Hutao.Web.Hoyolab.DynamicSecret;
|
||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.Verification;
|
||||
using Snap.Hutao.Web.Response;
|
||||
using System.Net.Http;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ using Snap.Hutao.ViewModel.User;
|
||||
using Snap.Hutao.Web.Hoyolab.Annotation;
|
||||
using Snap.Hutao.Web.Hoyolab.DynamicSecret;
|
||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.Avatar;
|
||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.Verification;
|
||||
using Snap.Hutao.Web.Response;
|
||||
using System.Net.Http;
|
||||
|
||||
@@ -46,9 +47,9 @@ internal sealed partial class GameRecordClient : IGameRecordClient
|
||||
{
|
||||
// Replace message
|
||||
resp.Message = SH.WebDailyNoteVerificationFailed;
|
||||
CardVerifier cardVerifier = serviceProvider.GetRequiredService<CardVerifier>();
|
||||
IGeetestCardVerifier verifier = serviceProvider.GetRequiredService<HomaGeetestCardVerifier>();
|
||||
|
||||
if (await cardVerifier.TryGetXrpcChallengeAsync(userAndUid.User, token).ConfigureAwait(false) is { } challenge)
|
||||
if (await verifier.TryValidateXrpcChallengeAsync(userAndUid.User, token).ConfigureAwait(false) is { } challenge)
|
||||
{
|
||||
resp = await httpClient
|
||||
.SetUser(userAndUid.User, CookieType.Cookie)
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Model.Entity;
|
||||
using Snap.Hutao.Web.Geetest;
|
||||
using Snap.Hutao.Web.Hutao.Geetest;
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.Verification;
|
||||
|
||||
[ConstructorGenerated]
|
||||
[Injection(InjectAs.Transient)]
|
||||
internal sealed partial class HomaGeetestCardVerifier : IGeetestCardVerifier
|
||||
{
|
||||
private readonly CardClient cardClient;
|
||||
private readonly HomaGeetestClient homaGeetestClient;
|
||||
|
||||
public async ValueTask<string?> TryValidateXrpcChallengeAsync(User user, CancellationToken token)
|
||||
{
|
||||
Response.Response<VerificationRegistration> registrationResponse = await cardClient.CreateVerificationAsync(user, token).ConfigureAwait(false);
|
||||
if (registrationResponse.IsOk())
|
||||
{
|
||||
VerificationRegistration registration = registrationResponse.Data;
|
||||
|
||||
GeetestResponse response = await homaGeetestClient.VerifyAsync(registration.Gt, registration.Challenge, token).ConfigureAwait(false);
|
||||
|
||||
if (response is { Code: 0, Data.Validate: string validate })
|
||||
{
|
||||
Response.Response<VerificationResult> verifyResponse = await cardClient.VerifyVerificationAsync(registration.Challenge, validate, token).ConfigureAwait(false);
|
||||
if (verifyResponse.IsOk())
|
||||
{
|
||||
VerificationResult result = verifyResponse.Data;
|
||||
|
||||
if (result.Challenge is not null)
|
||||
{
|
||||
return result.Challenge;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Model.Entity;
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.Verification;
|
||||
|
||||
internal interface IGeetestCardVerifier
|
||||
{
|
||||
ValueTask<string?> TryValidateXrpcChallengeAsync(User user, CancellationToken token);
|
||||
}
|
||||
@@ -4,14 +4,14 @@
|
||||
using Snap.Hutao.Model.Entity;
|
||||
using Snap.Hutao.Web.Geetest;
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.Takumi.GameRecord;
|
||||
namespace Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.Verification;
|
||||
|
||||
/// <summary>
|
||||
/// CardApi验证器
|
||||
/// </summary>
|
||||
[HighQuality]
|
||||
[Injection(InjectAs.Transient)]
|
||||
internal sealed class CardVerifier
|
||||
internal sealed class SlientGeetestCardVerifier : IGeetestCardVerifier
|
||||
{
|
||||
private readonly CardClient cardClient;
|
||||
private readonly GeetestClient geetestClient;
|
||||
@@ -21,7 +21,7 @@ internal sealed class CardVerifier
|
||||
/// </summary>
|
||||
/// <param name="cardClient">card客户端</param>
|
||||
/// <param name="geetestClient">极验客户端</param>
|
||||
public CardVerifier(CardClient cardClient, GeetestClient geetestClient)
|
||||
public SlientGeetestCardVerifier(CardClient cardClient, GeetestClient geetestClient)
|
||||
{
|
||||
this.cardClient = cardClient;
|
||||
this.geetestClient = geetestClient;
|
||||
@@ -33,7 +33,7 @@ internal sealed class CardVerifier
|
||||
/// <param name="user">用户</param>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>流水号</returns>
|
||||
public async ValueTask<string?> TryGetXrpcChallengeAsync(User user, CancellationToken token)
|
||||
public async ValueTask<string?> TryValidateXrpcChallengeAsync(User user, CancellationToken token)
|
||||
{
|
||||
Response.Response<VerificationRegistration> registrationResponse = await cardClient.CreateVerificationAsync(user, token).ConfigureAwait(false);
|
||||
if (registrationResponse.IsOk())
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.Takumi.GameRecord;
|
||||
namespace Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.Verification;
|
||||
|
||||
/// <summary>
|
||||
/// 验证注册
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.Takumi.GameRecord;
|
||||
namespace Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.Verification;
|
||||
|
||||
/// <summary>
|
||||
/// 验证结果
|
||||
|
||||
@@ -6,6 +6,7 @@ using Snap.Hutao.Service.Hutao;
|
||||
using Snap.Hutao.Web.Hutao.GachaLog;
|
||||
using Snap.Hutao.Web.Response;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.GachaLog;
|
||||
|
||||
@@ -28,7 +29,7 @@ internal sealed partial class HomaGachaLogClient
|
||||
/// <returns>祈愿统计信息</returns>
|
||||
public async ValueTask<Response<GachaEventStatistics>> GetGachaEventStatisticsAsync(CancellationToken token = default)
|
||||
{
|
||||
httpClient.DefaultRequestHeaders.Authorization = new("Bearer", hutaoUserOptions.Token);
|
||||
await httpClient.TrySetTokenAsync(hutaoUserOptions).ConfigureAwait(false);
|
||||
|
||||
Response<GachaEventStatistics>? resp = await httpClient
|
||||
.TryCatchGetFromJsonAsync<Response<GachaEventStatistics>>(HutaoEndpoints.GachaLogStatisticsCurrentEvents, options, logger, token)
|
||||
@@ -45,7 +46,7 @@ internal sealed partial class HomaGachaLogClient
|
||||
/// <returns>祈愿分布</returns>
|
||||
public async ValueTask<Response<GachaDistribution>> GetGachaDistributionAsync(GachaDistributionType distributionType, CancellationToken token = default)
|
||||
{
|
||||
httpClient.DefaultRequestHeaders.Authorization = new("Bearer", hutaoUserOptions.Token);
|
||||
await httpClient.TrySetTokenAsync(hutaoUserOptions).ConfigureAwait(false);
|
||||
|
||||
Response<GachaDistribution>? resp = await httpClient
|
||||
.TryCatchGetFromJsonAsync<Response<GachaDistribution>>(HutaoEndpoints.GachaLogStatisticsDistribution(distributionType), options, logger, token)
|
||||
@@ -62,7 +63,7 @@ internal sealed partial class HomaGachaLogClient
|
||||
[Obsolete("Use GetGachaEntriesAsync instead")]
|
||||
public async ValueTask<Response<List<string>>> GetUidsAsync(CancellationToken token = default)
|
||||
{
|
||||
httpClient.DefaultRequestHeaders.Authorization = new("Bearer", hutaoUserOptions.Token);
|
||||
await httpClient.TrySetTokenAsync(hutaoUserOptions).ConfigureAwait(false);
|
||||
|
||||
Response<List<string>>? resp = await httpClient
|
||||
.TryCatchGetFromJsonAsync<Response<List<string>>>(HutaoEndpoints.GachaLogUids, options, logger, token)
|
||||
@@ -78,7 +79,7 @@ internal sealed partial class HomaGachaLogClient
|
||||
/// <returns>Uid 列表</returns>
|
||||
public async ValueTask<Response<List<GachaEntry>>> GetGachaEntriesAsync(CancellationToken token = default)
|
||||
{
|
||||
httpClient.DefaultRequestHeaders.Authorization = new("Bearer", hutaoUserOptions.Token);
|
||||
await httpClient.TrySetTokenAsync(hutaoUserOptions).ConfigureAwait(false);
|
||||
|
||||
Response<List<GachaEntry>>? resp = await httpClient
|
||||
.TryCatchGetFromJsonAsync<Response<List<GachaEntry>>>(HutaoEndpoints.GachaLogEntries, options, logger, token)
|
||||
@@ -95,7 +96,7 @@ internal sealed partial class HomaGachaLogClient
|
||||
/// <returns>末尾Id</returns>
|
||||
public async ValueTask<Response<EndIds>> GetEndIdsAsync(string uid, CancellationToken token = default)
|
||||
{
|
||||
httpClient.DefaultRequestHeaders.Authorization = new("Bearer", hutaoUserOptions.Token);
|
||||
await httpClient.TrySetTokenAsync(hutaoUserOptions).ConfigureAwait(false);
|
||||
|
||||
Response<EndIds>? resp = await httpClient
|
||||
.TryCatchGetFromJsonAsync<Response<EndIds>>(HutaoEndpoints.GachaLogEndIds(uid), options, logger, token)
|
||||
@@ -113,7 +114,7 @@ internal sealed partial class HomaGachaLogClient
|
||||
/// <returns>云端祈愿记录</returns>
|
||||
public async ValueTask<Response<List<GachaItem>>> RetrieveGachaItemsAsync(string uid, EndIds endIds, CancellationToken token = default)
|
||||
{
|
||||
httpClient.DefaultRequestHeaders.Authorization = new("Bearer", hutaoUserOptions.Token);
|
||||
await httpClient.TrySetTokenAsync(hutaoUserOptions).ConfigureAwait(false);
|
||||
|
||||
UidAndEndIds uidAndEndIds = new(uid, endIds);
|
||||
|
||||
@@ -133,7 +134,7 @@ internal sealed partial class HomaGachaLogClient
|
||||
/// <returns>响应</returns>
|
||||
public async ValueTask<Response.Response> UploadGachaItemsAsync(string uid, List<GachaItem> gachaItems, CancellationToken token = default)
|
||||
{
|
||||
httpClient.DefaultRequestHeaders.Authorization = new("Bearer", hutaoUserOptions.Token);
|
||||
await httpClient.TrySetTokenAsync(hutaoUserOptions).ConfigureAwait(false);
|
||||
|
||||
UidAndItems uidAndItems = new(uid, gachaItems);
|
||||
|
||||
@@ -152,7 +153,7 @@ internal sealed partial class HomaGachaLogClient
|
||||
/// <returns>响应</returns>
|
||||
public async ValueTask<Response.Response> DeleteGachaItemsAsync(string uid, CancellationToken token = default)
|
||||
{
|
||||
httpClient.DefaultRequestHeaders.Authorization = new("Bearer", hutaoUserOptions.Token);
|
||||
await httpClient.TrySetTokenAsync(hutaoUserOptions).ConfigureAwait(false);
|
||||
|
||||
Response.Response? resp = await httpClient
|
||||
.TryCatchGetFromJsonAsync<Response<List<GachaItem>>>(HutaoEndpoints.GachaLogDelete(uid), options, logger, token)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Service.Hutao;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.GachaLog;
|
||||
|
||||
internal static class HomaPassportHttpClientAuthorizationExtension
|
||||
{
|
||||
public static async ValueTask TrySetTokenAsync(this HttpClient httpClient, HutaoUserOptions hutaoUserOptions)
|
||||
{
|
||||
string? token = await hutaoUserOptions.GetTokenAsync().ConfigureAwait(false);
|
||||
httpClient.DefaultRequestHeaders.Authorization = new("Bearer", token);
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,10 @@ internal sealed partial class HomaGeetestClient
|
||||
|
||||
public async ValueTask<GeetestResponse> VerifyAsync(string gt, string challenge, CancellationToken token)
|
||||
{
|
||||
httpClient.DefaultRequestHeaders.Authorization = new("Bearer", hutaoUserOptions.Token);
|
||||
await httpClient.TrySetTokenAsync(hutaoUserOptions).ConfigureAwait(false);
|
||||
|
||||
GeetestResponse? resp = await httpClient
|
||||
.TryCatchGetFromJsonAsync<GeetestResponse>(HutaoEndpoints.GeetestVerify(gt,challenge), options, logger, token)
|
||||
.TryCatchGetFromJsonAsync<GeetestResponse>(HutaoEndpoints.GeetestVerify(gt, challenge), options, logger, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
ArgumentNullException.ThrowIfNull(resp);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient;
|
||||
using Snap.Hutao.Web.Hutao.Model;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
using Snap.Hutao.Web.Response;
|
||||
using System.Net.Http;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
/// <summary>
|
||||
/// 出场率
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
/// <summary>
|
||||
/// 角色相关构筑
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
/// <summary>
|
||||
/// 角色搭配
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
/// <summary>
|
||||
/// 角色命座信息
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
/// <summary>
|
||||
/// 使用率
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using Microsoft.Extensions.Primitives;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model.Converter;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss.Converter;
|
||||
|
||||
/// <summary>
|
||||
/// 圣遗物套装转换器
|
||||
@@ -9,12 +9,12 @@ using Snap.Hutao.Web.Hoyolab;
|
||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord;
|
||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.Avatar;
|
||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.SpiralAbyss;
|
||||
using Snap.Hutao.Web.Hutao.Model;
|
||||
using Snap.Hutao.Web.Hutao.Model.Post;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss.Post;
|
||||
using Snap.Hutao.Web.Response;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
/// <summary>
|
||||
/// 胡桃API客户端
|
||||
@@ -190,7 +190,7 @@ internal sealed partial class HomaSpiralAbyssClient
|
||||
|
||||
if (charactersResponse.IsOk())
|
||||
{
|
||||
Response<SpiralAbyss> spiralAbyssResponse = await gameRecordClient
|
||||
Response<Hoyolab.Takumi.GameRecord.SpiralAbyss.SpiralAbyss> spiralAbyssResponse = await gameRecordClient
|
||||
.GetSpiralAbyssAsync(userAndUid, SpiralAbyssSchedule.Current, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
/// <summary>
|
||||
/// 物品与率
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
/// <summary>
|
||||
/// 统计数据
|
||||
@@ -4,7 +4,7 @@
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.Avatar;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model.Post;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss.Post;
|
||||
|
||||
/// <summary>
|
||||
/// 角色详情 角色
|
||||
@@ -4,7 +4,7 @@
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.SpiralAbyss;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model.Post;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss.Post;
|
||||
|
||||
/// <summary>
|
||||
/// 上下半信息
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.SpiralAbyss;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model.Post;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss.Post;
|
||||
|
||||
/// <summary>
|
||||
/// 层信息
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.SpiralAbyss;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model.Post;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss.Post;
|
||||
|
||||
/// <summary>
|
||||
/// 间信息
|
||||
@@ -4,7 +4,7 @@
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.SpiralAbyss;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model.Post;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss.Post;
|
||||
|
||||
/// <summary>
|
||||
/// 数值
|
||||
@@ -4,7 +4,7 @@
|
||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.Avatar;
|
||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.SpiralAbyss;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model.Post;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss.Post;
|
||||
|
||||
/// <summary>
|
||||
/// 记录
|
||||
@@ -19,7 +19,7 @@ internal sealed class SimpleRecord
|
||||
/// <param name="characters">详细的角色信息</param>
|
||||
/// <param name="spiralAbyss">深渊信息</param>
|
||||
/// <param name="reservedUserName">用户名</param>
|
||||
public SimpleRecord(string uid, List<Character> characters, SpiralAbyss spiralAbyss, string? reservedUserName)
|
||||
public SimpleRecord(string uid, List<Character> characters, Hoyolab.Takumi.GameRecord.SpiralAbyss.SpiralAbyss spiralAbyss, string? reservedUserName)
|
||||
{
|
||||
Uid = uid;
|
||||
Identity = "Snap Hutao"; // hardcoded Identity name
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.SpiralAbyss;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model.Post;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss.Post;
|
||||
|
||||
/// <summary>
|
||||
/// 深渊数据
|
||||
@@ -15,7 +15,7 @@ internal sealed class SimpleSpiralAbyss
|
||||
/// 构造一个新的深渊信息
|
||||
/// </summary>
|
||||
/// <param name="spiralAbyss">深渊信息</param>
|
||||
public SimpleSpiralAbyss(SpiralAbyss spiralAbyss)
|
||||
public SimpleSpiralAbyss(Hoyolab.Takumi.GameRecord.SpiralAbyss.SpiralAbyss spiralAbyss)
|
||||
{
|
||||
ScheduleId = spiralAbyss.ScheduleId;
|
||||
TotalBattleTimes = spiralAbyss.TotalBattleTimes;
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
/// <summary>
|
||||
/// 排行包装
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
/// <summary>
|
||||
/// 伤害值
|
||||
@@ -4,7 +4,7 @@
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
/// <summary>
|
||||
/// 圣遗物套装
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Web.Hutao.Model.Converter;
|
||||
using Snap.Hutao.Web.Hutao.SpiralAbyss.Converter;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
/// <summary>
|
||||
/// 包装圣遗物套装
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using Snap.Hutao.Core.Json.Converter;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
/// <summary>
|
||||
/// 队伍
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
/// <summary>
|
||||
/// 队伍出场次数
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
/// <summary>
|
||||
/// 用户信息
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
/// <summary>
|
||||
/// 武器相关构筑
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
using Snap.Hutao.Model.Primitive;
|
||||
|
||||
namespace Snap.Hutao.Web.Hutao.Model;
|
||||
namespace Snap.Hutao.Web.Hutao.SpiralAbyss;
|
||||
|
||||
/// <summary>
|
||||
/// 武器搭配
|
||||
Reference in New Issue
Block a user