From ee4197a18a32f654922081cbcc02efef423c79e4 Mon Sep 17 00:00:00 2001 From: DismissedLight <1686188646@qq.com> Date: Thu, 24 Nov 2022 13:40:14 +0800 Subject: [PATCH] fix code style --- .../Snap.Hutao/Core/Caching/ImageCache.cs | 4 +- .../Snap.Hutao/Package.appxmanifest | 2 +- .../Snap.Hutao/Web/Geetest/GeetestClient.cs | 42 +------------------ .../Snap.Hutao/Web/Geetest/GeetestData.cs | 27 ++++++++++++ .../Snap.Hutao/Web/Geetest/GeetestResult.cs | 23 ++++++++++ ...ttrbute.cs => IgnoreSetCookieAttribute.cs} | 1 + .../Web/Hoyolab/Takumi/Auth/AuthClient.cs | 3 +- .../Hoyolab/Takumi/GameRecord/CardClient.cs | 40 ------------------ .../Verification/VerificationRegistration.cs | 40 ++++++++++++++++++ .../Verification/VerificationResult.cs | 24 +++++++++++ 10 files changed, 120 insertions(+), 86 deletions(-) create mode 100644 src/Snap.Hutao/Snap.Hutao/Web/Geetest/GeetestData.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Web/Geetest/GeetestResult.cs rename src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Annotation/{IgnoreSetCookieAttrbute.cs => IgnoreSetCookieAttribute.cs} (77%) create mode 100644 src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/GameRecord/Verification/VerificationRegistration.cs create mode 100644 src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/GameRecord/Verification/VerificationResult.cs diff --git a/src/Snap.Hutao/Snap.Hutao/Core/Caching/ImageCache.cs b/src/Snap.Hutao/Snap.Hutao/Core/Caching/ImageCache.cs index 2b9a6a40..92f6e22f 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/Caching/ImageCache.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/Caching/ImageCache.cs @@ -25,7 +25,7 @@ public class ImageCache : IImageCache { private const string DateAccessedProperty = "System.DateAccessed"; - private static readonly ImmutableDictionary retryCountToDelay = new Dictionary() + private static readonly ImmutableDictionary RetryCountToDelay = new Dictionary() { [0] = TimeSpan.FromSeconds(4), [1] = TimeSpan.FromSeconds(16), @@ -239,7 +239,7 @@ public class ImageCache : IImageCache else { retryCount++; - TimeSpan delay = message.Headers.RetryAfter?.Delta ?? retryCountToDelay[retryCount]; + TimeSpan delay = message.Headers.RetryAfter?.Delta ?? RetryCountToDelay[retryCount]; await Task.Delay(delay).ConfigureAwait(false); } } diff --git a/src/Snap.Hutao/Snap.Hutao/Package.appxmanifest b/src/Snap.Hutao/Snap.Hutao/Package.appxmanifest index c8243158..eb02f63f 100644 --- a/src/Snap.Hutao/Snap.Hutao/Package.appxmanifest +++ b/src/Snap.Hutao/Snap.Hutao/Package.appxmanifest @@ -12,7 +12,7 @@ + Version="1.2.4.0" /> 胡桃 diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Geetest/GeetestClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Geetest/GeetestClient.cs index 1a1cd8a4..8507c345 100644 --- a/src/Snap.Hutao/Snap.Hutao/Web/Geetest/GeetestClient.cs +++ b/src/Snap.Hutao/Snap.Hutao/Web/Geetest/GeetestClient.cs @@ -21,6 +21,7 @@ internal class GeetestClient /// 构造一个新的极验客户端 /// /// http客户端 + /// Json 序列化选项 public GeetestClient(HttpClient httpClient, JsonSerializerOptions options) { this.httpClient = httpClient; @@ -64,44 +65,3 @@ internal class GeetestClient return GetAjaxAsync(registration.Gt, registration.Challenge); } } - -/// -/// 极验返回结果信息 -/// -public class GeetestResult -{ - /// - /// 成功失败的标识码 success - /// - [JsonPropertyName("status")] - public string Status { get; set; } = default!; - - /// - /// 返回数据,json格式 - /// - [JsonPropertyName("data")] - public T Data { get; set; } = default!; -} - -/// -/// 极验数据 -/// -public class GeetestData -{ - /// - /// 结果 - /// - [JsonPropertyName("result")] - public string Result { get; set; } = default!; - - /// - /// 验证 - /// - [JsonPropertyName("validate")] - public string? Validate { get; set; } - - /// - /// 分数 - /// - public int Score { get; set; } = default!; -} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Geetest/GeetestData.cs b/src/Snap.Hutao/Snap.Hutao/Web/Geetest/GeetestData.cs new file mode 100644 index 00000000..4cf82d0e --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Web/Geetest/GeetestData.cs @@ -0,0 +1,27 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +namespace Snap.Hutao.Web.Geetest; + +/// +/// 极验数据 +/// +public class GeetestData +{ + /// + /// 结果 + /// + [JsonPropertyName("result")] + public string Result { get; set; } = default!; + + /// + /// 验证 + /// + [JsonPropertyName("validate")] + public string? Validate { get; set; } + + /// + /// 分数 + /// + public int Score { get; set; } = default!; +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Geetest/GeetestResult.cs b/src/Snap.Hutao/Snap.Hutao/Web/Geetest/GeetestResult.cs new file mode 100644 index 00000000..dfbd5407 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Web/Geetest/GeetestResult.cs @@ -0,0 +1,23 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +namespace Snap.Hutao.Web.Geetest; + +/// +/// 极验返回结果信息 +/// +/// 数据类型 +public class GeetestResult +{ + /// + /// 成功失败的标识码 success + /// + [JsonPropertyName("status")] + public string Status { get; set; } = default!; + + /// + /// 返回数据,json格式 + /// + [JsonPropertyName("data")] + public T Data { get; set; } = default!; +} diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Annotation/IgnoreSetCookieAttrbute.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Annotation/IgnoreSetCookieAttribute.cs similarity index 77% rename from src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Annotation/IgnoreSetCookieAttrbute.cs rename to src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Annotation/IgnoreSetCookieAttribute.cs index 48cf4539..66ef1a8b 100644 --- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Annotation/IgnoreSetCookieAttrbute.cs +++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Annotation/IgnoreSetCookieAttribute.cs @@ -6,6 +6,7 @@ namespace Snap.Hutao.Web.Hoyolab.Annotation; /// /// 指示相关的类忽略Http请求的Set-Cookie头 /// +[AttributeUsage(AttributeTargets.Class, AllowMultiple =false, Inherited =false)] internal class IgnoreSetCookieAttribute : Attribute { } \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Auth/AuthClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Auth/AuthClient.cs index 4b4c83e0..098571ef 100644 --- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Auth/AuthClient.cs +++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/Auth/AuthClient.cs @@ -61,8 +61,7 @@ internal class AuthClient /// /// 获取 MultiToken /// - /// 登录票证 - /// uid + /// login cookie /// 取消令牌 /// 包含token的字典 public async Task> GetMultiTokenByLoginTicketAsync(Cookie cookie, CancellationToken token) diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/GameRecord/CardClient.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/GameRecord/CardClient.cs index a5f0b0a5..a9a6d572 100644 --- a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/GameRecord/CardClient.cs +++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/GameRecord/CardClient.cs @@ -106,44 +106,4 @@ public class CardClient [JsonPropertyName("geetest_seccode")] public string GeetestSeccode { get; set; } } -} - -/// -/// 验证注册 -/// -public class VerificationRegistration -{ - /// - /// 极验流水号 - /// - [JsonPropertyName("challenge")] - public string Challenge { get; set; } = default!; - - /// - /// 极验Id - /// - [JsonPropertyName("gt")] - public string Gt { get; set; } = default!; - - /// - /// 新验证 - /// - public int NewCaptcha { get; set; } - - /// - /// 是否成功注册 - /// - public int Success { get; set; } -} - -/// -/// 验证结果 -/// -public class VerificationResult -{ - /// - /// 极验流水号 - /// - [JsonPropertyName("challenge")] - public string? Challenge { get; set; } } \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/GameRecord/Verification/VerificationRegistration.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/GameRecord/Verification/VerificationRegistration.cs new file mode 100644 index 00000000..8c6ea123 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/GameRecord/Verification/VerificationRegistration.cs @@ -0,0 +1,40 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +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.Widget; +using Snap.Hutao.Web.Response; +using System.Net.Http; + +namespace Snap.Hutao.Web.Hoyolab.Takumi.GameRecord; + +/// +/// 验证注册 +/// +public class VerificationRegistration +{ + /// + /// 极验流水号 + /// + [JsonPropertyName("challenge")] + public string Challenge { get; set; } = default!; + + /// + /// 极验Id + /// + [JsonPropertyName("gt")] + public string Gt { get; set; } = default!; + + /// + /// 新验证 + /// + public int NewCaptcha { get; set; } + + /// + /// 是否成功注册 + /// + public int Success { get; set; } +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/GameRecord/Verification/VerificationResult.cs b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/GameRecord/Verification/VerificationResult.cs new file mode 100644 index 00000000..0255fd05 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Web/Hoyolab/Takumi/GameRecord/Verification/VerificationResult.cs @@ -0,0 +1,24 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +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.Widget; +using Snap.Hutao.Web.Response; +using System.Net.Http; + +namespace Snap.Hutao.Web.Hoyolab.Takumi.GameRecord; + +/// +/// 验证结果 +/// +public class VerificationResult +{ + /// + /// 极验流水号 + /// + [JsonPropertyName("challenge")] + public string? Challenge { get; set; } +} \ No newline at end of file