Add daily reward claim support for hoyolab user & fix typo

This commit is contained in:
Xhichn
2023-03-15 23:38:42 +08:00
parent a543bf3091
commit e24a7436b4
6 changed files with 32 additions and 6 deletions

View File

@@ -29,6 +29,11 @@ internal static class CoreEnvironment
/// </summary>
public const string HoyolabMobileUA = $"Mozilla/5.0 (Linux; Android 12) Mobile miHoYoBBS/{HoyolabXrpcVersion}";
/// <summary>
/// Hoyolab iPhone 移动端请求UA
/// </summary>
public const string HoyolabOsMobileUA = "Mozilla/5.0 (iPhone; CPU iPhone OS 16_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) miHoYoBBSOversea/2.28.0";
/// <summary>
/// 米游社 Rpc 版本
/// </summary>

View File

@@ -106,7 +106,7 @@ internal sealed class User : ObservableObject
User user = new(inner);
bool isOk = false;
// TODO: need a flag to indentify hoyoverse account
// TODO: need a flag to identify hoyoverse account
if (user.Entity.Stoken != null)
{
isOk = await user.InitializeCoreAsync(token).ConfigureAwait(false);

View File

@@ -62,7 +62,7 @@ internal sealed class DailyNoteNotifier
string? attribution = SH.ServiceDailyNoteNotifierAttribution;
// TODO: need a flag to indentify hoyoverse account
// TODO: need a flag to identify hoyoverse account
// For global server, stoken is null
if (entry.User.Stoken == null)
{

View File

@@ -47,9 +47,19 @@ internal sealed partial class SignInWebViewDialog : ContentDialog
return;
}
coreWebView2.SetCookie(user.CookieToken, user.Ltoken, null).SetMobileUserAgent();
signInJsInterface = new(coreWebView2, scope.ServiceProvider);
coreWebView2.Navigate("https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?act_id=e202009291139501");
// TODO: need a flag to identify hoyoverse account
if (user.Stoken == null)
{
coreWebView2.SetCookie(user.CookieToken, user.Ltoken, null).SetOsMobileUserAgent();
signInJsInterface = new(coreWebView2, scope.ServiceProvider);
coreWebView2.Navigate("https://act.hoyolab.com/ys/event/signin-sea-v3/index.html?act_id=e202102251931481&hyl_presentation_style=fullscreen");
}
else
{
coreWebView2.SetCookie(user.CookieToken, user.Ltoken, null).SetMobileUserAgent();
signInJsInterface = new(coreWebView2, scope.ServiceProvider);
coreWebView2.Navigate("https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?act_id=e202009291139501");
}
}
private void OnContentDialogClosed(ContentDialog sender, ContentDialogClosedEventArgs args)

View File

@@ -23,6 +23,17 @@ internal static class CoreWebView2Extension
return webView;
}
/// <summary>
/// 设置 移动端UA
/// </summary>
/// <param name="webView">webview2</param>
/// <returns>链式调用的WebView2</returns>
public static CoreWebView2 SetOsMobileUserAgent(this CoreWebView2 webView)
{
webView.Settings.UserAgent = Core.CoreEnvironment.HoyolabOsMobileUA;
return webView;
}
/// <summary>
/// 设置WebView2的Cookie
/// </summary>

View File

@@ -44,7 +44,7 @@ internal sealed class CalculateClient
public async Task<Response<Consumption>> ComputeAsync(Model.Entity.User user, AvatarPromotionDelta delta, CancellationToken token = default)
{
Response<Consumption>? resp;
// TODO: need a flag to indentify hoyoverse account
// TODO: need a flag to identify hoyoverse account
if (user.Stoken == null)
{
resp = await httpClient