mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
impl #902
This commit is contained in:
@@ -25,9 +25,17 @@ internal sealed partial class SignInService : ISignInService
|
||||
|
||||
if (resultResponse.IsOk())
|
||||
{
|
||||
int index = DateTimeOffset.Now.Day - 1;
|
||||
Award award = rewardResponse.Data.Awards[index];
|
||||
return new(true, SH.ServiceSignInSuccessRewardFormat.Format(award.Name, award.Count));
|
||||
Response<SignInRewardInfo> infoResponse = await signInClient.GetInfoAsync(userAndUid, token).ConfigureAwait(false);
|
||||
if (infoResponse.IsOk())
|
||||
{
|
||||
int index = infoResponse.Data.TotalSignDay - 1;
|
||||
Award award = rewardResponse.Data.Awards[index];
|
||||
return new(true, SH.ServiceSignInSuccessRewardFormat.Format(award.Name, award.Count));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new(false, "获取签到次数失败");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -88,7 +88,8 @@ internal partial class WebViewer : UserControl, IRecipient<UserChangedMessage>
|
||||
if (!string.IsNullOrEmpty(source))
|
||||
{
|
||||
await coreWebView2.DeleteCookiesAsync(".mihoyo.com").ConfigureAwait(true);
|
||||
coreWebView2.SetCookie(user.CookieToken, user.LToken, user.SToken).SetMobileUserAgent();
|
||||
coreWebView2.SetCookie(user.CookieToken, user.LToken, user.SToken);
|
||||
_ = userAndUid.User.IsOversea ? coreWebView2.SetMobileOverseaUserAgent() : coreWebView2.SetMobileUserAgent();
|
||||
jsInterface = SourceProvider.CreateJsInterface(serviceProvider, coreWebView2, userAndUid);
|
||||
|
||||
CoreWebView2Navigator navigator = new(coreWebView2);
|
||||
|
||||
@@ -209,15 +209,37 @@
|
||||
</AppBarButton.Flyout>
|
||||
</AppBarButton>
|
||||
<AppBarButton
|
||||
x:Name="SignInRewardButton"
|
||||
Width="{StaticResource LargeAppBarButtonWidth}"
|
||||
MaxWidth="{StaticResource LargeAppBarButtonWidth}"
|
||||
Margin="2,-4"
|
||||
AllowFocusOnInteraction="True"
|
||||
Command="{Binding ClaimSignInRewardCommand}"
|
||||
CommandParameter="{Binding Source={RelativeSource Mode=Self}}"
|
||||
CommandParameter="{Binding ElementName=SignInRewardButton}"
|
||||
Icon="{shcm:FontIcon Glyph=}"
|
||||
Label="{shcm:ResourceString Name=ViewUserCookieOperationSignInRewardAction}"
|
||||
Style="{StaticResource DefaultAppBarButtonStyle}"/>
|
||||
Style="{StaticResource DefaultAppBarButtonStyle}">
|
||||
<FlyoutBase.AttachedFlyout>
|
||||
<Flyout
|
||||
LightDismissOverlayMode="On"
|
||||
Placement="Full"
|
||||
ShouldConstrainToRootBounds="False">
|
||||
<Flyout.FlyoutPresenterStyle>
|
||||
<Style BasedOn="{StaticResource DefaultFlyoutPresenterStyle}" TargetType="FlyoutPresenter">
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
<Setter Property="CornerRadius" Value="0"/>
|
||||
</Style>
|
||||
</Flyout.FlyoutPresenterStyle>
|
||||
<Grid>
|
||||
<shvc:WebViewer>
|
||||
<shvc:WebViewer.SourceProvider>
|
||||
<shvu:SignInWebViewerSouce/>
|
||||
</shvc:WebViewer.SourceProvider>
|
||||
</shvc:WebViewer>
|
||||
</Grid>
|
||||
</Flyout>
|
||||
</FlyoutBase.AttachedFlyout>
|
||||
</AppBarButton>
|
||||
<AppBarButton
|
||||
Width="{StaticResource LargeAppBarButtonWidth}"
|
||||
MaxWidth="{StaticResource LargeAppBarButtonWidth}"
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.Web.WebView2.Core;
|
||||
using Snap.Hutao.View.Control;
|
||||
using Snap.Hutao.Web.Bridge;
|
||||
|
||||
namespace Snap.Hutao.ViewModel.User;
|
||||
|
||||
internal sealed class SignInWebViewerSouce : DependencyObject, IWebViewerSource
|
||||
{
|
||||
public MiHoYoJSInterface CreateJsInterface(IServiceProvider serviceProvider, CoreWebView2 coreWebView2, UserAndUid userAndUid)
|
||||
{
|
||||
return userAndUid.User.IsOversea
|
||||
? serviceProvider.CreateInstance<SignInJSInterfaceOversea>(coreWebView2, userAndUid)
|
||||
: serviceProvider.CreateInstance<SignInJSInterface>(coreWebView2, userAndUid);
|
||||
}
|
||||
|
||||
public string GetSource(UserAndUid userAndUid)
|
||||
{
|
||||
return userAndUid.User.IsOversea
|
||||
? "https://act.hoyolab.com/ys/event/signin-sea-v3/index.html?act_id=e202102251931481"
|
||||
: "https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?act_id=e202009291139501";
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
using Microsoft.Web.WebView2.Core;
|
||||
using Snap.Hutao.Core;
|
||||
using Snap.Hutao.Core.ExceptionService;
|
||||
using Snap.Hutao.Core.IO.DataTransfer;
|
||||
@@ -12,10 +11,8 @@ using Snap.Hutao.Service.Navigation;
|
||||
using Snap.Hutao.Service.Notification;
|
||||
using Snap.Hutao.Service.SignIn;
|
||||
using Snap.Hutao.Service.User;
|
||||
using Snap.Hutao.View.Control;
|
||||
using Snap.Hutao.View.Dialog;
|
||||
using Snap.Hutao.View.Page;
|
||||
using Snap.Hutao.Web.Bridge;
|
||||
using Snap.Hutao.Web.Hoyolab;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text;
|
||||
@@ -263,19 +260,4 @@ internal sealed partial class UserViewModel : ObservableObject
|
||||
{
|
||||
await Launcher.LaunchUriAsync(new(documentationProvider.GetDocumentation()));
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class SignInWebViewerSouce : IWebViewerSource
|
||||
{
|
||||
public MiHoYoJSInterface CreateJsInterface(IServiceProvider serviceProvider, CoreWebView2 coreWebView2, UserAndUid userAndUid)
|
||||
{
|
||||
return userAndUid.User.IsOversea
|
||||
? serviceProvider.CreateInstance<SignInJSInterfaceOversea>(coreWebView2, userAndUid)
|
||||
: serviceProvider.CreateInstance<SignInJSInterface>(coreWebView2, userAndUid);
|
||||
}
|
||||
|
||||
public string GetSource(UserAndUid userAndUid)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user