mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
Add daily reward claim support for hoyolab user & fix typo
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user