mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
refactor user initialization
This commit is contained in:
@@ -75,18 +75,18 @@ internal sealed class User : ObservableObject
|
|||||||
set => inner.CookieToken = value;
|
set => inner.CookieToken = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="EntityUser.Ltoken"/>
|
/// <inheritdoc cref="EntityUser.LToken"/>
|
||||||
public Cookie? Ltoken
|
public Cookie? LToken
|
||||||
{
|
{
|
||||||
get => inner.Ltoken;
|
get => inner.LToken;
|
||||||
set => inner.Ltoken = value;
|
set => inner.LToken = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="EntityUser.Stoken"/>
|
/// <inheritdoc cref="EntityUser.SToken"/>
|
||||||
public Cookie? Stoken
|
public Cookie? SToken
|
||||||
{
|
{
|
||||||
get => inner.Stoken;
|
get => inner.SToken;
|
||||||
set => inner.Stoken = value;
|
set => inner.SToken = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -145,93 +145,127 @@ internal sealed class User : ObservableObject
|
|||||||
{
|
{
|
||||||
if (isInitialized)
|
if (isInitialized)
|
||||||
{
|
{
|
||||||
|
// Prevent multiple initialization.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Stoken == null)
|
if (SToken == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (IServiceScope scope = Ioc.Default.CreateScope())
|
using (IServiceScope scope = Ioc.Default.CreateScope())
|
||||||
{
|
{
|
||||||
Response<UserFullInfoWrapper> response = await scope.ServiceProvider
|
if (!await TrySetUserInfoAsync(scope.ServiceProvider, token).ConfigureAwait(false))
|
||||||
.GetRequiredService<UserClient>()
|
|
||||||
.GetUserFullInfoAsync(Entity, token)
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
UserInfo = response.Data?.UserInfo;
|
|
||||||
|
|
||||||
// 自动填充 Ltoken
|
|
||||||
if (Ltoken == null)
|
|
||||||
{
|
{
|
||||||
Response<LtokenWrapper> ltokenResponse = await scope.ServiceProvider
|
return false;
|
||||||
.GetRequiredService<PassportClient2>()
|
|
||||||
.GetLtokenBySTokenAsync(Entity, token)
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
|
|
||||||
if (ltokenResponse.IsOk())
|
|
||||||
{
|
|
||||||
Cookie ltokenCookie = Cookie.Parse($"ltuid={Entity.Aid};ltoken={ltokenResponse.Data.Ltoken}");
|
|
||||||
Entity.Ltoken = ltokenCookie;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Response<ActionTicketWrapper> actionTicketResponse = await scope.ServiceProvider
|
if (!await TrySetLTokenAsync(scope.ServiceProvider, token).ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!await TrySetUserGameRolesAsync(scope.ServiceProvider, token).ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await TrySetCookieTokenAsync(scope.ServiceProvider, token).ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectedUserGameRole = UserGameRoles.FirstOrFirstOrDefault(role => role.IsChosen);
|
||||||
|
return isInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> TrySetLTokenAsync(IServiceProvider provider, CancellationToken token)
|
||||||
|
{
|
||||||
|
if (LToken != null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Response<LtokenWrapper> lTokenResponse = await provider
|
||||||
|
.GetRequiredService<PassportClient2>()
|
||||||
|
.GetLTokenBySTokenAsync(Entity, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (lTokenResponse.IsOk())
|
||||||
|
{
|
||||||
|
LToken = Cookie.Parse($"{Cookie.LTUID}={Entity.Aid};{Cookie.LTOKEN}={lTokenResponse.Data.Ltoken}");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> TrySetCookieTokenAsync(IServiceProvider provider, CancellationToken token)
|
||||||
|
{
|
||||||
|
if (CookieToken != null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Response<UidCookieToken> cookieTokenResponse = await provider
|
||||||
|
.GetRequiredService<PassportClient2>()
|
||||||
|
.GetCookieAccountInfoBySTokenAsync(Entity, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (cookieTokenResponse.IsOk())
|
||||||
|
{
|
||||||
|
CookieToken = Cookie.Parse($"{Cookie.ACCOUNT_ID}={Entity.Aid};{Cookie.COOKIE_TOKEN}={cookieTokenResponse.Data.CookieToken}");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> TrySetUserInfoAsync(IServiceProvider provider, CancellationToken token)
|
||||||
|
{
|
||||||
|
Response<UserFullInfoWrapper> response = await provider
|
||||||
|
.GetRequiredService<UserClient>()
|
||||||
|
.GetUserFullInfoAsync(Entity, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
UserInfo = response.Data?.UserInfo;
|
||||||
|
return UserInfo != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> TrySetUserGameRolesAsync(IServiceProvider provider, CancellationToken token)
|
||||||
|
{
|
||||||
|
Response<ActionTicketWrapper> actionTicketResponse = await provider
|
||||||
.GetRequiredService<AuthClient>()
|
.GetRequiredService<AuthClient>()
|
||||||
.GetActionTicketByStokenAsync("game_role", Entity)
|
.GetActionTicketByStokenAsync("game_role", Entity)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (actionTicketResponse.IsOk())
|
if (actionTicketResponse.IsOk())
|
||||||
|
{
|
||||||
|
string actionTicket = actionTicketResponse.Data.Ticket;
|
||||||
|
|
||||||
|
Response<ListWrapper<UserGameRole>> userGameRolesResponse = await provider
|
||||||
|
.GetRequiredService<BindingClient>()
|
||||||
|
.GetUserGameRolesByActionTicketAsync(actionTicket, Entity, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (userGameRolesResponse.IsOk())
|
||||||
{
|
{
|
||||||
string actionTicket = actionTicketResponse.Data.Ticket;
|
UserGameRoles = userGameRolesResponse.Data.List;
|
||||||
|
return UserGameRoles.Any();
|
||||||
Response<ListWrapper<UserGameRole>> userGameRolesResponse = await scope.ServiceProvider
|
|
||||||
.GetRequiredService<BindingClient>()
|
|
||||||
.GetUserGameRolesByActionTicketAsync(actionTicket, Entity, token)
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
|
|
||||||
if (userGameRolesResponse.IsOk())
|
|
||||||
{
|
|
||||||
UserGameRoles = userGameRolesResponse.Data.List;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自动填充 CookieToken
|
|
||||||
if (CookieToken == null)
|
|
||||||
{
|
|
||||||
Response<UidCookieToken> cookieTokenResponse = await scope.ServiceProvider
|
|
||||||
.GetRequiredService<PassportClient2>()
|
|
||||||
.GetCookieAccountInfoBySTokenAsync(Entity, token)
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
|
|
||||||
if (cookieTokenResponse.IsOk())
|
|
||||||
{
|
|
||||||
Cookie cookieTokenCookie = Cookie.Parse($"account_id={Entity.Aid};cookie_token={cookieTokenResponse.Data.CookieToken}");
|
|
||||||
Entity.CookieToken = cookieTokenCookie;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
SelectedUserGameRole = UserGameRoles.FirstOrFirstOrDefault(role => role.IsChosen);
|
{
|
||||||
|
return false;
|
||||||
isInitialized = true;
|
}
|
||||||
|
|
||||||
return UserInfo != null && UserGameRoles.Any();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ internal sealed class UserConfiguration : IEntityTypeConfiguration<User>
|
|||||||
.HasColumnType("TEXT")
|
.HasColumnType("TEXT")
|
||||||
.HasConversion(e => e!.ToString(), e => Cookie.Parse(e));
|
.HasConversion(e => e!.ToString(), e => Cookie.Parse(e));
|
||||||
|
|
||||||
builder.Property(e => e.Ltoken)
|
builder.Property(e => e.LToken)
|
||||||
.HasColumnType("TEXT")
|
.HasColumnType("TEXT")
|
||||||
.HasConversion(e => e!.ToString(), e => Cookie.Parse(e));
|
.HasConversion(e => e!.ToString(), e => Cookie.Parse(e));
|
||||||
|
|
||||||
builder.Property(e => e.Stoken)
|
builder.Property(e => e.SToken)
|
||||||
.HasColumnType("TEXT")
|
.HasColumnType("TEXT")
|
||||||
.HasConversion(e => e!.ToString(), e => Cookie.Parse(e));
|
.HasConversion(e => e!.ToString(), e => Cookie.Parse(e));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,14 +43,16 @@ internal sealed class User : ISelectable
|
|||||||
public Cookie? CookieToken { get; set; }
|
public Cookie? CookieToken { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户的 Ltoken
|
/// 用户的 LToken
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Cookie? Ltoken { get; set; }
|
[Column("Ltoken")] // DO NOT RENAME
|
||||||
|
public Cookie? LToken { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户的 Stoken V2
|
/// 用户的 SToken V2
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Cookie? Stoken { get; set; }
|
[Column("Stoken")] // DO NOT RENAME
|
||||||
|
public Cookie? SToken { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否为国际服账号
|
/// 是否为国际服账号
|
||||||
@@ -68,6 +70,6 @@ internal sealed class User : ISelectable
|
|||||||
_ = cookie.TryGetAsLtoken(out Cookie? ltoken);
|
_ = cookie.TryGetAsLtoken(out Cookie? ltoken);
|
||||||
_ = cookie.TryGetAsCookieToken(out Cookie? cookieToken);
|
_ = cookie.TryGetAsCookieToken(out Cookie? cookieToken);
|
||||||
|
|
||||||
return new() { Stoken = stoken, Ltoken = ltoken, CookieToken = cookieToken };
|
return new() { SToken = stoken, LToken = ltoken, CookieToken = cookieToken };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -210,8 +210,8 @@ internal class UserService : IUserService
|
|||||||
|
|
||||||
if (cookie.TryGetAsStoken(out Cookie? stoken))
|
if (cookie.TryGetAsStoken(out Cookie? stoken))
|
||||||
{
|
{
|
||||||
user.Stoken = stoken;
|
user.SToken = stoken;
|
||||||
user.Ltoken = cookie.TryGetAsLtoken(out Cookie? ltoken) ? ltoken : user.Ltoken;
|
user.LToken = cookie.TryGetAsLtoken(out Cookie? ltoken) ? ltoken : user.LToken;
|
||||||
user.CookieToken = cookie.TryGetAsCookieToken(out Cookie? cookieToken) ? cookieToken : user.CookieToken;
|
user.CookieToken = cookie.TryGetAsCookieToken(out Cookie? cookieToken) ? cookieToken : user.CookieToken;
|
||||||
|
|
||||||
await appDbContext.Users.UpdateAndSaveAsync(user.Entity).ConfigureAwait(false);
|
await appDbContext.Users.UpdateAndSaveAsync(user.Entity).ConfigureAwait(false);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ internal sealed partial class AdoptCalculatorDialog : ContentDialog
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
coreWebView2.SetCookie(user.CookieToken, user.Ltoken, null).SetMobileUserAgent();
|
coreWebView2.SetCookie(user.CookieToken, user.LToken, null).SetMobileUserAgent();
|
||||||
jsInterface = new(coreWebView2, scope.ServiceProvider);
|
jsInterface = new(coreWebView2, scope.ServiceProvider);
|
||||||
jsInterface.ClosePageRequested += OnClosePageRequested;
|
jsInterface.ClosePageRequested += OnClosePageRequested;
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ internal sealed partial class CommunityGameRecordDialog : ContentDialog
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
coreWebView2.SetCookie(user.CookieToken, user.Ltoken, null).SetMobileUserAgent();
|
coreWebView2.SetCookie(user.CookieToken, user.LToken, null).SetMobileUserAgent();
|
||||||
jsInterface = new(coreWebView2, scope.ServiceProvider);
|
jsInterface = new(coreWebView2, scope.ServiceProvider);
|
||||||
jsInterface.ClosePageRequested += OnClosePageRequested;
|
jsInterface.ClosePageRequested += OnClosePageRequested;
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ internal sealed partial class DailyNoteVerificationDialog : ContentDialog
|
|||||||
CoreWebView2 coreWebView2 = WebView.CoreWebView2;
|
CoreWebView2 coreWebView2 = WebView.CoreWebView2;
|
||||||
|
|
||||||
Model.Entity.User user = userAndUid.User;
|
Model.Entity.User user = userAndUid.User;
|
||||||
coreWebView2.SetCookie(user.CookieToken, user.Ltoken, null).SetMobileUserAgent();
|
coreWebView2.SetCookie(user.CookieToken, user.LToken, null).SetMobileUserAgent();
|
||||||
jsInterface = new(coreWebView2, scope.ServiceProvider);
|
jsInterface = new(coreWebView2, scope.ServiceProvider);
|
||||||
jsInterface.ClosePageRequested += OnClosePageRequested;
|
jsInterface.ClosePageRequested += OnClosePageRequested;
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ internal sealed partial class SignInWebViewDialog : ContentDialog
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
coreWebView2.SetCookie(user.CookieToken, user.Ltoken, null).SetMobileUserAgent();
|
coreWebView2.SetCookie(user.CookieToken, user.LToken, null).SetMobileUserAgent();
|
||||||
signInJsInterface = new(coreWebView2, scope.ServiceProvider);
|
signInJsInterface = new(coreWebView2, scope.ServiceProvider);
|
||||||
coreWebView2.Navigate("https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?act_id=e202009291139501");
|
coreWebView2.Navigate("https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?act_id=e202009291139501");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// Licensed under the MIT license.
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
using Snap.Hutao.Control;
|
using Snap.Hutao.Control;
|
||||||
using Snap.Hutao.ViewModel;
|
using Snap.Hutao.ViewModel.SpiralAbyss;
|
||||||
|
|
||||||
namespace Snap.Hutao.View.Page;
|
namespace Snap.Hutao.View.Page;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
// Copyright (c) DGP Studio. All rights reserved.
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
// Licensed under the MIT license.
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using Snap.Hutao.Model.Binding;
|
||||||
using Snap.Hutao.Model.Intrinsic;
|
using Snap.Hutao.Model.Intrinsic;
|
||||||
using Snap.Hutao.Model.Primitive;
|
using Snap.Hutao.Model.Primitive;
|
||||||
|
|
||||||
namespace Snap.Hutao.Model.Binding.SpiralAbyss;
|
namespace Snap.Hutao.ViewModel.SpiralAbyss;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 角色视图
|
/// 角色视图
|
||||||
@@ -16,11 +17,11 @@ internal class AvatarView : INameIconSide
|
|||||||
/// 构造一个新的角色视图
|
/// 构造一个新的角色视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="metaAvatar">角色</param>
|
/// <param name="metaAvatar">角色</param>
|
||||||
public AvatarView(Metadata.Avatar.Avatar metaAvatar)
|
public AvatarView(Model.Metadata.Avatar.Avatar metaAvatar)
|
||||||
{
|
{
|
||||||
Name = metaAvatar.Name;
|
Name = metaAvatar.Name;
|
||||||
Icon = Metadata.Converter.AvatarIconConverter.IconNameToUri(metaAvatar.Icon);
|
Icon = Model.Metadata.Converter.AvatarIconConverter.IconNameToUri(metaAvatar.Icon);
|
||||||
SideIcon = Metadata.Converter.AvatarIconConverter.IconNameToUri(metaAvatar.SideIcon);
|
SideIcon = Model.Metadata.Converter.AvatarIconConverter.IconNameToUri(metaAvatar.SideIcon);
|
||||||
Quality = metaAvatar.Quality;
|
Quality = metaAvatar.Quality;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ internal class AvatarView : INameIconSide
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="avatarId">角色Id</param>
|
/// <param name="avatarId">角色Id</param>
|
||||||
/// <param name="idAvatarMap">Id角色映射</param>
|
/// <param name="idAvatarMap">Id角色映射</param>
|
||||||
public AvatarView(AvatarId avatarId, Dictionary<AvatarId, Metadata.Avatar.Avatar> idAvatarMap)
|
public AvatarView(AvatarId avatarId, Dictionary<AvatarId, Model.Metadata.Avatar.Avatar> idAvatarMap)
|
||||||
: this(idAvatarMap[avatarId])
|
: this(idAvatarMap[avatarId])
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
using Snap.Hutao.Model.Primitive;
|
using Snap.Hutao.Model.Primitive;
|
||||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.SpiralAbyss;
|
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.SpiralAbyss;
|
||||||
|
|
||||||
namespace Snap.Hutao.Model.Binding.SpiralAbyss;
|
namespace Snap.Hutao.ViewModel.SpiralAbyss;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上下半视图
|
/// 上下半视图
|
||||||
@@ -17,7 +17,7 @@ internal sealed class BattleView
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="battle">战斗</param>
|
/// <param name="battle">战斗</param>
|
||||||
/// <param name="idAvatarMap">Id角色映射</param>
|
/// <param name="idAvatarMap">Id角色映射</param>
|
||||||
public BattleView(Battle battle, Dictionary<AvatarId, Metadata.Avatar.Avatar> idAvatarMap)
|
public BattleView(Battle battle, Dictionary<AvatarId, Model.Metadata.Avatar.Avatar> idAvatarMap)
|
||||||
{
|
{
|
||||||
Time = DateTimeOffset.FromUnixTimeSeconds(battle.Timestamp).ToLocalTime().ToString("yyyy.MM.dd HH:mm:ss");
|
Time = DateTimeOffset.FromUnixTimeSeconds(battle.Timestamp).ToLocalTime().ToString("yyyy.MM.dd HH:mm:ss");
|
||||||
Avatars = battle.Avatars.Select(a => new AvatarView(a.Id, idAvatarMap)).ToList();
|
Avatars = battle.Avatars.Select(a => new AvatarView(a.Id, idAvatarMap)).ToList();
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
using Snap.Hutao.Model.Primitive;
|
using Snap.Hutao.Model.Primitive;
|
||||||
|
|
||||||
namespace Snap.Hutao.Model.Binding.SpiralAbyss;
|
namespace Snap.Hutao.ViewModel.SpiralAbyss;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 层视图
|
/// 层视图
|
||||||
@@ -16,7 +16,7 @@ internal sealed class FloorView
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="floor">层</param>
|
/// <param name="floor">层</param>
|
||||||
/// <param name="idAvatarMap">Id角色映射</param>
|
/// <param name="idAvatarMap">Id角色映射</param>
|
||||||
public FloorView(Web.Hoyolab.Takumi.GameRecord.SpiralAbyss.Floor floor, Dictionary<AvatarId, Metadata.Avatar.Avatar> idAvatarMap)
|
public FloorView(Web.Hoyolab.Takumi.GameRecord.SpiralAbyss.Floor floor, Dictionary<AvatarId, Model.Metadata.Avatar.Avatar> idAvatarMap)
|
||||||
{
|
{
|
||||||
Index = string.Format(SH.ModelBindingHutaoComplexRankFloor, floor.Index);
|
Index = string.Format(SH.ModelBindingHutaoComplexRankFloor, floor.Index);
|
||||||
SettleTime = $"{DateTimeOffset.FromUnixTimeSeconds(floor.SettleTime).ToLocalTime():yyyy.MM.dd HH:mm:ss}";
|
SettleTime = $"{DateTimeOffset.FromUnixTimeSeconds(floor.SettleTime).ToLocalTime():yyyy.MM.dd HH:mm:ss}";
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
using Snap.Hutao.Model.Primitive;
|
using Snap.Hutao.Model.Primitive;
|
||||||
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.SpiralAbyss;
|
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.SpiralAbyss;
|
||||||
|
|
||||||
namespace Snap.Hutao.Model.Binding.SpiralAbyss;
|
namespace Snap.Hutao.ViewModel.SpiralAbyss;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 间视图
|
/// 间视图
|
||||||
@@ -17,7 +17,7 @@ internal sealed class LevelView
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="level">间</param>
|
/// <param name="level">间</param>
|
||||||
/// <param name="idAvatarMap">Id角色映射</param>
|
/// <param name="idAvatarMap">Id角色映射</param>
|
||||||
public LevelView(Level level, Dictionary<AvatarId, Metadata.Avatar.Avatar> idAvatarMap)
|
public LevelView(Level level, Dictionary<AvatarId, Model.Metadata.Avatar.Avatar> idAvatarMap)
|
||||||
{
|
{
|
||||||
Index = string.Format(SH.ModelBindingHutaoComplexRankLevel, level.Index);
|
Index = string.Format(SH.ModelBindingHutaoComplexRankLevel, level.Index);
|
||||||
Star = level.Star;
|
Star = level.Star;
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
using Snap.Hutao.Model.Primitive;
|
using Snap.Hutao.Model.Primitive;
|
||||||
|
|
||||||
namespace Snap.Hutao.Model.Binding.SpiralAbyss;
|
namespace Snap.Hutao.ViewModel.SpiralAbyss;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 排行角色
|
/// 排行角色
|
||||||
@@ -17,7 +17,7 @@ internal sealed class RankAvatar : AvatarView
|
|||||||
/// <param name="value">值</param>
|
/// <param name="value">值</param>
|
||||||
/// <param name="avatarId">角色Id</param>
|
/// <param name="avatarId">角色Id</param>
|
||||||
/// <param name="idAvatarMap">Id角色映射</param>
|
/// <param name="idAvatarMap">Id角色映射</param>
|
||||||
public RankAvatar(int value, AvatarId avatarId, Dictionary<AvatarId, Metadata.Avatar.Avatar> idAvatarMap)
|
public RankAvatar(int value, AvatarId avatarId, Dictionary<AvatarId, Model.Metadata.Avatar.Avatar> idAvatarMap)
|
||||||
: base(avatarId, idAvatarMap)
|
: base(avatarId, idAvatarMap)
|
||||||
{
|
{
|
||||||
Value = value;
|
Value = value;
|
||||||
@@ -5,7 +5,6 @@ using CommunityToolkit.Mvvm.Input;
|
|||||||
using CommunityToolkit.Mvvm.Messaging;
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Snap.Hutao.Message;
|
using Snap.Hutao.Message;
|
||||||
using Snap.Hutao.Model.Binding.SpiralAbyss;
|
|
||||||
using Snap.Hutao.Model.Binding.User;
|
using Snap.Hutao.Model.Binding.User;
|
||||||
using Snap.Hutao.Model.Entity;
|
using Snap.Hutao.Model.Entity;
|
||||||
using Snap.Hutao.Model.Metadata;
|
using Snap.Hutao.Model.Metadata;
|
||||||
@@ -18,7 +17,7 @@ using Snap.Hutao.Web.Hutao;
|
|||||||
using Snap.Hutao.Web.Hutao.Model.Post;
|
using Snap.Hutao.Web.Hutao.Model.Post;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
namespace Snap.Hutao.ViewModel;
|
namespace Snap.Hutao.ViewModel.SpiralAbyss;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 深渊记录视图模型
|
/// 深渊记录视图模型
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
using Snap.Hutao.Model.Primitive;
|
using Snap.Hutao.Model.Primitive;
|
||||||
|
|
||||||
namespace Snap.Hutao.Model.Binding.SpiralAbyss;
|
namespace Snap.Hutao.ViewModel.SpiralAbyss;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 深渊视图
|
/// 深渊视图
|
||||||
@@ -16,7 +16,7 @@ internal sealed class SpiralAbyssView
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="spiralAbyss">深渊信息</param>
|
/// <param name="spiralAbyss">深渊信息</param>
|
||||||
/// <param name="idAvatarMap">Id角色映射</param>
|
/// <param name="idAvatarMap">Id角色映射</param>
|
||||||
public SpiralAbyssView(Web.Hoyolab.Takumi.GameRecord.SpiralAbyss.SpiralAbyss spiralAbyss, Dictionary<AvatarId, Metadata.Avatar.Avatar> idAvatarMap)
|
public SpiralAbyssView(Web.Hoyolab.Takumi.GameRecord.SpiralAbyss.SpiralAbyss spiralAbyss, Dictionary<AvatarId, Model.Metadata.Avatar.Avatar> idAvatarMap)
|
||||||
{
|
{
|
||||||
Schedule = string.Format(SH.ModelEntitySpiralAbyssScheduleFormat, spiralAbyss.ScheduleId);
|
Schedule = string.Format(SH.ModelEntitySpiralAbyssScheduleFormat, spiralAbyss.ScheduleId);
|
||||||
TotalBattleTimes = spiralAbyss.TotalBattleTimes;
|
TotalBattleTimes = spiralAbyss.TotalBattleTimes;
|
||||||
@@ -194,10 +194,10 @@ internal sealed class UserViewModel : ObservableObject
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string cookieString = new StringBuilder()
|
string cookieString = new StringBuilder()
|
||||||
.Append(user!.Stoken)
|
.Append(user!.SToken)
|
||||||
.AppendIf(user.Stoken != null, ';')
|
.AppendIf(user.SToken != null, ';')
|
||||||
.Append(user.Ltoken)
|
.Append(user.LToken)
|
||||||
.AppendIf(user.Ltoken != null, ';')
|
.AppendIf(user.LToken != null, ';')
|
||||||
.Append(user.CookieToken)
|
.Append(user.CookieToken)
|
||||||
.ToString();
|
.ToString();
|
||||||
|
|
||||||
|
|||||||
@@ -105,8 +105,8 @@ internal class MiHoYoJSInterface
|
|||||||
{
|
{
|
||||||
Data = new()
|
Data = new()
|
||||||
{
|
{
|
||||||
[Cookie.LTUID] = user.Ltoken![Cookie.LTUID],
|
[Cookie.LTUID] = user.LToken![Cookie.LTUID],
|
||||||
[Cookie.LTOKEN] = user.Ltoken[Cookie.LTOKEN],
|
[Cookie.LTOKEN] = user.LToken[Cookie.LTOKEN],
|
||||||
[Cookie.LOGIN_TICKET] = string.Empty,
|
[Cookie.LOGIN_TICKET] = string.Empty,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -203,7 +203,7 @@ internal class MiHoYoJSInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
await ThreadHelper.SwitchToMainThreadAsync();
|
await ThreadHelper.SwitchToMainThreadAsync();
|
||||||
webView.SetCookie(user.CookieToken, user.Ltoken);
|
webView.SetCookie(user.CookieToken, user.LToken);
|
||||||
return new() { Data = new() { [Cookie.COOKIE_TOKEN] = user.CookieToken![Cookie.COOKIE_TOKEN] } };
|
return new() { Data = new() { [Cookie.COOKIE_TOKEN] = user.CookieToken![Cookie.COOKIE_TOKEN] } };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,11 +43,11 @@ internal sealed class AccountClient
|
|||||||
/// <param name="data">提交数据</param>
|
/// <param name="data">提交数据</param>
|
||||||
/// <param name="token">取消令牌</param>
|
/// <param name="token">取消令牌</param>
|
||||||
/// <returns>用户角色信息</returns>
|
/// <returns>用户角色信息</returns>
|
||||||
[ApiInformation(Cookie = CookieType.Stoken, Salt = SaltType.K2)]
|
[ApiInformation(Cookie = CookieType.SToken, Salt = SaltType.K2)]
|
||||||
public async Task<Response<GameAuthKey>> GenerateAuthenticationKeyAsync(User user, GenAuthKeyData data, CancellationToken token = default)
|
public async Task<Response<GameAuthKey>> GenerateAuthenticationKeyAsync(User user, GenAuthKeyData data, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
Response<GameAuthKey>? resp = await httpClient
|
Response<GameAuthKey>? resp = await httpClient
|
||||||
.SetUser(user, CookieType.Stoken)
|
.SetUser(user, CookieType.SToken)
|
||||||
.SetReferer(ApiEndpoints.AppMihoyoReferer)
|
.SetReferer(ApiEndpoints.AppMihoyoReferer)
|
||||||
.UseDynamicSecret(DynamicSecretVersion.Gen1, SaltType.K2, false)
|
.UseDynamicSecret(DynamicSecretVersion.Gen1, SaltType.K2, false)
|
||||||
.TryCatchPostAsJsonAsync<GenAuthKeyData, Response<GameAuthKey>>(ApiEndpoints.AppAuthGenAuthKey, data, options, logger, token)
|
.TryCatchPostAsJsonAsync<GenAuthKeyData, Response<GameAuthKey>>(ApiEndpoints.AppAuthGenAuthKey, data, options, logger, token)
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ internal sealed class UserClient
|
|||||||
/// <param name="user">用户</param>
|
/// <param name="user">用户</param>
|
||||||
/// <param name="token">取消令牌</param>
|
/// <param name="token">取消令牌</param>
|
||||||
/// <returns>详细信息</returns>
|
/// <returns>详细信息</returns>
|
||||||
[ApiInformation(Cookie = CookieType.Stoken, Salt = SaltType.K2)]
|
[ApiInformation(Cookie = CookieType.SToken, Salt = SaltType.K2)]
|
||||||
public async Task<Response<UserFullInfoWrapper>> GetUserFullInfoAsync(Model.Entity.User user, CancellationToken token = default)
|
public async Task<Response<UserFullInfoWrapper>> GetUserFullInfoAsync(Model.Entity.User user, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
Response<UserFullInfoWrapper>? resp = await httpClient
|
Response<UserFullInfoWrapper>? resp = await httpClient
|
||||||
.SetUser(user, CookieType.Stoken)
|
.SetUser(user, CookieType.SToken)
|
||||||
.SetReferer(ApiEndpoints.BbsReferer)
|
.SetReferer(ApiEndpoints.BbsReferer)
|
||||||
.UseDynamicSecret(DynamicSecretVersion.Gen1, SaltType.K2, true)
|
.UseDynamicSecret(DynamicSecretVersion.Gen1, SaltType.K2, true)
|
||||||
.TryCatchGetFromJsonAsync<Response<UserFullInfoWrapper>>(ApiEndpoints.UserFullInfoQuery(user.Aid!), options, logger, token)
|
.TryCatchGetFromJsonAsync<Response<UserFullInfoWrapper>>(ApiEndpoints.UserFullInfoQuery(user.Aid!), options, logger, token)
|
||||||
|
|||||||
@@ -23,15 +23,15 @@ internal enum CookieType
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 需要 Ltoken
|
/// 需要 Ltoken
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Ltoken = 0B0010,
|
LToken = 0B0010,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 需要 CookieToken 与 Ltoken
|
/// 需要 CookieToken 与 LToken
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Cookie = CookieToken | Ltoken,
|
Cookie = CookieToken | LToken,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 需要 Stoken
|
/// 需要 SToken
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Stoken = 0B0100,
|
SToken = 0B0100,
|
||||||
}
|
}
|
||||||
@@ -30,14 +30,14 @@ internal static class HoyolabHttpClientExtension
|
|||||||
stringBuilder.Append(user.CookieToken).AppendIf(user.CookieToken != null, ';');
|
stringBuilder.Append(user.CookieToken).AppendIf(user.CookieToken != null, ';');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cookie.HasFlag(CookieType.Ltoken))
|
if (cookie.HasFlag(CookieType.LToken))
|
||||||
{
|
{
|
||||||
stringBuilder.Append(user.Ltoken).AppendIf(user.Ltoken != null, ';');
|
stringBuilder.Append(user.LToken).AppendIf(user.LToken != null, ';');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cookie.HasFlag(CookieType.Stoken))
|
if (cookie.HasFlag(CookieType.SToken))
|
||||||
{
|
{
|
||||||
stringBuilder.Append(user.Stoken).AppendIf(user.Stoken != null, ';');
|
stringBuilder.Append(user.SToken).AppendIf(user.SToken != null, ';');
|
||||||
}
|
}
|
||||||
|
|
||||||
string result = stringBuilder.ToString();
|
string result = stringBuilder.ToString();
|
||||||
|
|||||||
@@ -39,11 +39,11 @@ internal sealed class PassportClient
|
|||||||
/// <param name="user">用户</param>
|
/// <param name="user">用户</param>
|
||||||
/// <param name="token">取消令牌</param>
|
/// <param name="token">取消令牌</param>
|
||||||
/// <returns>验证信息</returns>
|
/// <returns>验证信息</returns>
|
||||||
[ApiInformation(Cookie = CookieType.Ltoken)]
|
[ApiInformation(Cookie = CookieType.LToken)]
|
||||||
public async Task<Response<UserInfoWrapper>> VerifyLtokenAsync(User user, CancellationToken token)
|
public async Task<Response<UserInfoWrapper>> VerifyLtokenAsync(User user, CancellationToken token)
|
||||||
{
|
{
|
||||||
Response<UserInfoWrapper>? response = await httpClient
|
Response<UserInfoWrapper>? response = await httpClient
|
||||||
.SetUser(user, CookieType.Ltoken)
|
.SetUser(user, CookieType.LToken)
|
||||||
.TryCatchPostAsJsonAsync<Timestamp, Response<UserInfoWrapper>>(ApiEndpoints.AccountVerifyLtoken, new(), options, logger, token)
|
.TryCatchPostAsJsonAsync<Timestamp, Response<UserInfoWrapper>>(ApiEndpoints.AccountVerifyLtoken, new(), options, logger, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
|||||||
@@ -64,11 +64,11 @@ internal sealed class PassportClient2
|
|||||||
/// <param name="user">用户</param>
|
/// <param name="user">用户</param>
|
||||||
/// <param name="token">取消令牌</param>
|
/// <param name="token">取消令牌</param>
|
||||||
/// <returns>cookie token</returns>
|
/// <returns>cookie token</returns>
|
||||||
[ApiInformation(Cookie = CookieType.Stoken, Salt = SaltType.PROD)]
|
[ApiInformation(Cookie = CookieType.SToken, Salt = SaltType.PROD)]
|
||||||
public async Task<Response<UidCookieToken>> GetCookieAccountInfoBySTokenAsync(User user, CancellationToken token = default)
|
public async Task<Response<UidCookieToken>> GetCookieAccountInfoBySTokenAsync(User user, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
Response<UidCookieToken>? resp = await httpClient
|
Response<UidCookieToken>? resp = await httpClient
|
||||||
.SetUser(user, CookieType.Stoken)
|
.SetUser(user, CookieType.SToken)
|
||||||
.UseDynamicSecret(DynamicSecretVersion.Gen2, SaltType.PROD, true)
|
.UseDynamicSecret(DynamicSecretVersion.Gen2, SaltType.PROD, true)
|
||||||
.TryCatchGetFromJsonAsync<Response<UidCookieToken>>(ApiEndpoints.AccountGetCookieTokenBySToken, options, logger, token)
|
.TryCatchGetFromJsonAsync<Response<UidCookieToken>>(ApiEndpoints.AccountGetCookieTokenBySToken, options, logger, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
@@ -82,11 +82,11 @@ internal sealed class PassportClient2
|
|||||||
/// <param name="user">用户</param>
|
/// <param name="user">用户</param>
|
||||||
/// <param name="token">取消令牌</param>
|
/// <param name="token">取消令牌</param>
|
||||||
/// <returns>uid 与 cookie token</returns>
|
/// <returns>uid 与 cookie token</returns>
|
||||||
[ApiInformation(Cookie = CookieType.Stoken, Salt = SaltType.PROD)]
|
[ApiInformation(Cookie = CookieType.SToken, Salt = SaltType.PROD)]
|
||||||
public async Task<Response<LtokenWrapper>> GetLtokenBySTokenAsync(User user, CancellationToken token)
|
public async Task<Response<LtokenWrapper>> GetLTokenBySTokenAsync(User user, CancellationToken token)
|
||||||
{
|
{
|
||||||
Response<LtokenWrapper>? resp = await httpClient
|
Response<LtokenWrapper>? resp = await httpClient
|
||||||
.SetUser(user, CookieType.Stoken)
|
.SetUser(user, CookieType.SToken)
|
||||||
.UseDynamicSecret(DynamicSecretVersion.Gen2, SaltType.PROD, true)
|
.UseDynamicSecret(DynamicSecretVersion.Gen2, SaltType.PROD, true)
|
||||||
.TryCatchGetFromJsonAsync<Response<LtokenWrapper>>(ApiEndpoints.AccountGetLtokenByStoken, options, logger, token)
|
.TryCatchGetFromJsonAsync<Response<LtokenWrapper>>(ApiEndpoints.AccountGetLtokenByStoken, options, logger, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|||||||
@@ -42,13 +42,13 @@ internal sealed class AuthClient
|
|||||||
/// <param name="action">操作</param>
|
/// <param name="action">操作</param>
|
||||||
/// <param name="user">用户</param>
|
/// <param name="user">用户</param>
|
||||||
/// <returns>操作凭证</returns>
|
/// <returns>操作凭证</returns>
|
||||||
[ApiInformation(Cookie = CookieType.Stoken, Salt = SaltType.K2)]
|
[ApiInformation(Cookie = CookieType.SToken, Salt = SaltType.K2)]
|
||||||
public async Task<Response<ActionTicketWrapper>> GetActionTicketByStokenAsync(string action, User user)
|
public async Task<Response<ActionTicketWrapper>> GetActionTicketByStokenAsync(string action, User user)
|
||||||
{
|
{
|
||||||
Response<ActionTicketWrapper>? resp = await httpClient
|
Response<ActionTicketWrapper>? resp = await httpClient
|
||||||
.SetUser(user, CookieType.Stoken)
|
.SetUser(user, CookieType.SToken)
|
||||||
.UseDynamicSecret(DynamicSecretVersion.Gen1, SaltType.K2, true)
|
.UseDynamicSecret(DynamicSecretVersion.Gen1, SaltType.K2, true)
|
||||||
.TryCatchGetFromJsonAsync<Response<ActionTicketWrapper>>(ApiEndpoints.AuthActionTicket(action, user.Stoken?[Cookie.STOKEN] ?? string.Empty, user.Aid!), options, logger)
|
.TryCatchGetFromJsonAsync<Response<ActionTicketWrapper>>(ApiEndpoints.AuthActionTicket(action, user.SToken?[Cookie.STOKEN] ?? string.Empty, user.Aid!), options, logger)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
return Response.Response.DefaultIfNull(resp);
|
return Response.Response.DefaultIfNull(resp);
|
||||||
|
|||||||
@@ -40,13 +40,13 @@ internal sealed class BindingClient
|
|||||||
/// <param name="user">用户</param>
|
/// <param name="user">用户</param>
|
||||||
/// <param name="token">取消令牌</param>
|
/// <param name="token">取消令牌</param>
|
||||||
/// <returns>用户角色信息</returns>
|
/// <returns>用户角色信息</returns>
|
||||||
[ApiInformation(Cookie = CookieType.Ltoken)]
|
[ApiInformation(Cookie = CookieType.LToken)]
|
||||||
public async Task<Response<ListWrapper<UserGameRole>>> GetUserGameRolesByActionTicketAsync(string actionTicket, User user, CancellationToken token = default)
|
public async Task<Response<ListWrapper<UserGameRole>>> GetUserGameRolesByActionTicketAsync(string actionTicket, User user, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
string url = ApiEndpoints.UserGameRolesByActionTicket(actionTicket);
|
string url = ApiEndpoints.UserGameRolesByActionTicket(actionTicket);
|
||||||
|
|
||||||
Response<ListWrapper<UserGameRole>>? resp = await httpClient
|
Response<ListWrapper<UserGameRole>>? resp = await httpClient
|
||||||
.SetUser(user, CookieType.Ltoken)
|
.SetUser(user, CookieType.LToken)
|
||||||
.TryCatchGetFromJsonAsync<Response<ListWrapper<UserGameRole>>>(url, options, logger, token)
|
.TryCatchGetFromJsonAsync<Response<ListWrapper<UserGameRole>>>(url, options, logger, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
|||||||
@@ -41,11 +41,11 @@ internal sealed class BindingClient2
|
|||||||
/// <param name="user">用户</param>
|
/// <param name="user">用户</param>
|
||||||
/// <param name="token">取消令牌</param>
|
/// <param name="token">取消令牌</param>
|
||||||
/// <returns>用户角色信息</returns>
|
/// <returns>用户角色信息</returns>
|
||||||
[ApiInformation(Cookie = CookieType.Stoken, Salt = SaltType.LK2)]
|
[ApiInformation(Cookie = CookieType.SToken, Salt = SaltType.LK2)]
|
||||||
public async Task<List<UserGameRole>> GetUserGameRolesByStokenAsync(User user, CancellationToken token = default)
|
public async Task<List<UserGameRole>> GetUserGameRolesByStokenAsync(User user, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
Response<ListWrapper<UserGameRole>>? resp = await httpClient
|
Response<ListWrapper<UserGameRole>>? resp = await httpClient
|
||||||
.SetUser(user, CookieType.Stoken)
|
.SetUser(user, CookieType.SToken)
|
||||||
.UseDynamicSecret(DynamicSecretVersion.Gen1, SaltType.LK2, true)
|
.UseDynamicSecret(DynamicSecretVersion.Gen1, SaltType.LK2, true)
|
||||||
.TryCatchGetFromJsonAsync<Response<ListWrapper<UserGameRole>>>(ApiEndpoints.UserGameRolesByStoken, options, logger, token)
|
.TryCatchGetFromJsonAsync<Response<ListWrapper<UserGameRole>>>(ApiEndpoints.UserGameRolesByStoken, options, logger, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
@@ -61,11 +61,11 @@ internal sealed class BindingClient2
|
|||||||
/// <param name="data">提交数据</param>
|
/// <param name="data">提交数据</param>
|
||||||
/// <param name="token">取消令牌</param>
|
/// <param name="token">取消令牌</param>
|
||||||
/// <returns>用户角色信息</returns>
|
/// <returns>用户角色信息</returns>
|
||||||
[ApiInformation(Cookie = CookieType.Stoken, Salt = SaltType.LK2)]
|
[ApiInformation(Cookie = CookieType.SToken, Salt = SaltType.LK2)]
|
||||||
public async Task<Response<GameAuthKey>> GenerateAuthenticationKeyAsync(User user, GenAuthKeyData data, CancellationToken token = default)
|
public async Task<Response<GameAuthKey>> GenerateAuthenticationKeyAsync(User user, GenAuthKeyData data, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
Response<GameAuthKey>? resp = await httpClient
|
Response<GameAuthKey>? resp = await httpClient
|
||||||
.SetUser(user, CookieType.Stoken)
|
.SetUser(user, CookieType.SToken)
|
||||||
.SetReferer(ApiEndpoints.AppMihoyoReferer)
|
.SetReferer(ApiEndpoints.AppMihoyoReferer)
|
||||||
.UseDynamicSecret(DynamicSecretVersion.Gen1, SaltType.LK2, true)
|
.UseDynamicSecret(DynamicSecretVersion.Gen1, SaltType.LK2, true)
|
||||||
.TryCatchPostAsJsonAsync<GenAuthKeyData, Response<GameAuthKey>>(ApiEndpoints.BindingGenAuthKey, data, options, logger, token)
|
.TryCatchPostAsJsonAsync<GenAuthKeyData, Response<GameAuthKey>>(ApiEndpoints.BindingGenAuthKey, data, options, logger, token)
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ internal sealed class CardClient
|
|||||||
public async Task<Response<VerificationRegistration>> CreateVerificationAsync(User user, CancellationToken token)
|
public async Task<Response<VerificationRegistration>> CreateVerificationAsync(User user, CancellationToken token)
|
||||||
{
|
{
|
||||||
Response<VerificationRegistration>? resp = await httpClient
|
Response<VerificationRegistration>? resp = await httpClient
|
||||||
.SetUser(user, CookieType.Ltoken)
|
.SetUser(user, CookieType.LToken)
|
||||||
.UseDynamicSecret(DynamicSecretVersion.Gen2, SaltType.X4, false)
|
.UseDynamicSecret(DynamicSecretVersion.Gen2, SaltType.X4, false)
|
||||||
.TryCatchGetFromJsonAsync<Response<VerificationRegistration>>(ApiEndpoints.CardCreateVerification, options, logger, token)
|
.TryCatchGetFromJsonAsync<Response<VerificationRegistration>>(ApiEndpoints.CardCreateVerification, options, logger, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
@@ -77,11 +77,11 @@ internal sealed class CardClient
|
|||||||
/// <param name="user">用户</param>
|
/// <param name="user">用户</param>
|
||||||
/// <param name="token">取消令牌</param>
|
/// <param name="token">取消令牌</param>
|
||||||
/// <returns>桌面小组件数据</returns>
|
/// <returns>桌面小组件数据</returns>
|
||||||
[ApiInformation(Cookie = CookieType.Stoken, Salt = SaltType.X6)]
|
[ApiInformation(Cookie = CookieType.SToken, Salt = SaltType.X6)]
|
||||||
public async Task<Response<DataWrapper<WidgetData>>> GetWidgetDataAsync(User user, CancellationToken token)
|
public async Task<Response<DataWrapper<WidgetData>>> GetWidgetDataAsync(User user, CancellationToken token)
|
||||||
{
|
{
|
||||||
Response<DataWrapper<WidgetData>>? resp = await httpClient
|
Response<DataWrapper<WidgetData>>? resp = await httpClient
|
||||||
.SetUser(user, CookieType.Stoken)
|
.SetUser(user, CookieType.SToken)
|
||||||
.UseDynamicSecret(DynamicSecretVersion.Gen2, SaltType.X6, false)
|
.UseDynamicSecret(DynamicSecretVersion.Gen2, SaltType.X6, false)
|
||||||
.TryCatchGetFromJsonAsync<Response<DataWrapper<WidgetData>>>(ApiEndpoints.CardWidgetData, options, logger, token)
|
.TryCatchGetFromJsonAsync<Response<DataWrapper<WidgetData>>>(ApiEndpoints.CardWidgetData, options, logger, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|||||||
@@ -82,11 +82,11 @@ internal sealed class GameRecordClient
|
|||||||
/// <param name="userAndUid">用户与角色</param>
|
/// <param name="userAndUid">用户与角色</param>
|
||||||
/// <param name="token">取消令牌</param>
|
/// <param name="token">取消令牌</param>
|
||||||
/// <returns>玩家的基础信息</returns>
|
/// <returns>玩家的基础信息</returns>
|
||||||
[ApiInformation(Cookie = CookieType.Ltoken, Salt = SaltType.X4)]
|
[ApiInformation(Cookie = CookieType.LToken, Salt = SaltType.X4)]
|
||||||
public async Task<Response<PlayerInfo>> GetPlayerInfoAsync(UserAndUid userAndUid, CancellationToken token = default)
|
public async Task<Response<PlayerInfo>> GetPlayerInfoAsync(UserAndUid userAndUid, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
Response<PlayerInfo>? resp = await httpClient
|
Response<PlayerInfo>? resp = await httpClient
|
||||||
.SetUser(userAndUid.User, CookieType.Ltoken)
|
.SetUser(userAndUid.User, CookieType.LToken)
|
||||||
.UseDynamicSecret(DynamicSecretVersion.Gen2, SaltType.X4, false)
|
.UseDynamicSecret(DynamicSecretVersion.Gen2, SaltType.X4, false)
|
||||||
.TryCatchGetFromJsonAsync<Response<PlayerInfo>>(ApiEndpoints.GameRecordIndex(userAndUid.Uid), options, logger, token)
|
.TryCatchGetFromJsonAsync<Response<PlayerInfo>>(ApiEndpoints.GameRecordIndex(userAndUid.Uid), options, logger, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
@@ -119,11 +119,11 @@ internal sealed class GameRecordClient
|
|||||||
/// <param name="userAndUid">用户与角色</param>
|
/// <param name="userAndUid">用户与角色</param>
|
||||||
/// <param name="token">取消令牌</param>
|
/// <param name="token">取消令牌</param>
|
||||||
/// <returns>角色基本信息</returns>
|
/// <returns>角色基本信息</returns>
|
||||||
[ApiInformation(Cookie = CookieType.Ltoken, Salt = SaltType.X4)]
|
[ApiInformation(Cookie = CookieType.LToken, Salt = SaltType.X4)]
|
||||||
public async Task<Response<BasicRoleInfo>> GetRoleBasicInfoAsync(UserAndUid userAndUid, CancellationToken token = default)
|
public async Task<Response<BasicRoleInfo>> GetRoleBasicInfoAsync(UserAndUid userAndUid, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
Response<BasicRoleInfo>? resp = await httpClient
|
Response<BasicRoleInfo>? resp = await httpClient
|
||||||
.SetUser(userAndUid.User, CookieType.Ltoken)
|
.SetUser(userAndUid.User, CookieType.LToken)
|
||||||
.UseDynamicSecret(DynamicSecretVersion.Gen2, SaltType.X4, false)
|
.UseDynamicSecret(DynamicSecretVersion.Gen2, SaltType.X4, false)
|
||||||
.TryCatchGetFromJsonAsync<Response<BasicRoleInfo>>(ApiEndpoints.GameRecordRoleBasicInfo(userAndUid.Uid), options, logger, token)
|
.TryCatchGetFromJsonAsync<Response<BasicRoleInfo>>(ApiEndpoints.GameRecordRoleBasicInfo(userAndUid.Uid), options, logger, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
@@ -138,13 +138,13 @@ internal sealed class GameRecordClient
|
|||||||
/// <param name="playerInfo">玩家的基础信息</param>
|
/// <param name="playerInfo">玩家的基础信息</param>
|
||||||
/// <param name="token">取消令牌</param>
|
/// <param name="token">取消令牌</param>
|
||||||
/// <returns>角色列表</returns>
|
/// <returns>角色列表</returns>
|
||||||
[ApiInformation(Cookie = CookieType.Ltoken, Salt = SaltType.X4)]
|
[ApiInformation(Cookie = CookieType.LToken, Salt = SaltType.X4)]
|
||||||
public async Task<Response<CharacterWrapper>> GetCharactersAsync(UserAndUid userAndUid, PlayerInfo playerInfo, CancellationToken token = default)
|
public async Task<Response<CharacterWrapper>> GetCharactersAsync(UserAndUid userAndUid, PlayerInfo playerInfo, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
CharacterData data = new(userAndUid.Uid, playerInfo.Avatars.Select(x => x.Id));
|
CharacterData data = new(userAndUid.Uid, playerInfo.Avatars.Select(x => x.Id));
|
||||||
|
|
||||||
Response<CharacterWrapper>? resp = await httpClient
|
Response<CharacterWrapper>? resp = await httpClient
|
||||||
.SetUser(userAndUid.User, CookieType.Ltoken)
|
.SetUser(userAndUid.User, CookieType.LToken)
|
||||||
.UseDynamicSecret(DynamicSecretVersion.Gen2, SaltType.X4, false)
|
.UseDynamicSecret(DynamicSecretVersion.Gen2, SaltType.X4, false)
|
||||||
.TryCatchPostAsJsonAsync<CharacterData, Response<CharacterWrapper>>(ApiEndpoints.GameRecordCharacter, data, options, logger, token)
|
.TryCatchPostAsJsonAsync<CharacterData, Response<CharacterWrapper>>(ApiEndpoints.GameRecordCharacter, data, options, logger, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user