refactor dialogs

This commit is contained in:
DismissedLight
2023-08-12 16:24:12 +08:00
parent 71fcbc367c
commit ade6613fe1
47 changed files with 840 additions and 922 deletions

View File

@@ -59,6 +59,8 @@
<SolidColorBrush x:Key="BlueBrush" Color="#FF5180CB"/>
<SolidColorBrush x:Key="PurpleBrush" Color="#FFA156E0"/>
<SolidColorBrush x:Key="OrangeBrush" Color="#FFBC6932"/>
<SolidColorBrush x:Key="GuaranteePullBrush" Color="#FF0063FF"/>
<SolidColorBrush x:Key="UpPullBrush" Color="#FFFFA400"/>
<!-- Settings -->
<x:Double x:Key="SettingsCardSpacing">3</x:Double>
<x:Double x:Key="SettingsCardMinHeight">0</x:Double>
@@ -103,8 +105,12 @@
<x:String x:Key="UI_EmotionIcon293">https://static.snapgenshin.com/EmotionIcon/UI_EmotionIcon293.png</x:String>
<!-- FontIcon Content -->
<x:String x:Key="FontIconContentAdd">&#xE710;</x:String>
<x:String x:Key="FontIconContentSetting">&#xE713;</x:String>
<x:String x:Key="FontIconContentRefresh">&#xE72C;</x:String>
<x:String x:Key="FontIconContentDelete">&#xE74D;</x:String>
<x:String x:Key="FontIconContentFolder">&#xE8B7;</x:String>
<x:String x:Key="FontIconContentCheckList">&#xE9D5;</x:String>
<x:String x:Key="FontIconContentAsteriskBadge12">&#xEDAD;</x:String>
<x:String x:Key="FontIconContentZipFolder">&#xF012;</x:String>
<!-- Converters -->

View File

@@ -13,8 +13,8 @@ namespace Snap.Hutao.Control.Panel;
[DependencyProperty("Current", typeof(string), List)]
internal sealed partial class PanelSelector : Segmented
{
private const string List = nameof(List);
private const string Grid = nameof(Grid);
public const string List = nameof(List);
public const string Grid = nameof(Grid);
private static readonly Dictionary<int, string> IndexTypeMap = new()
{

View File

@@ -102,4 +102,11 @@ internal static class ThrowHelper
{
throw new RuntimeEnvironmentException(message, inner);
}
[DoesNotReturn]
[MethodImpl(MethodImplOptions.NoInlining)]
public static NotSupportedException NotSupported()
{
throw new NotSupportedException();
}
}

View File

@@ -16,8 +16,9 @@ internal static class IniSerializer
/// </summary>
/// <param name="fileStream">文件流</param>
/// <returns>Ini 元素集合</returns>
public static IEnumerable<IniElement> Deserialize(FileStream fileStream)
public static List<IniElement> Deserialize(FileStream fileStream)
{
List<IniElement> results = new();
using (StreamReader reader = new(fileStream))
{
while (reader.ReadLine() is { } line)
@@ -31,20 +32,22 @@ internal static class IniSerializer
if (lineSpan[0] is '[')
{
yield return new IniSection(lineSpan[1..^1].ToString());
results.Add(new IniSection(lineSpan[1..^1].ToString()));
}
if (lineSpan[0] is ';')
{
yield return new IniComment(lineSpan[1..].ToString());
results.Add(new IniComment(lineSpan[1..].ToString()));
}
if (lineSpan.TrySplitIntoTwo('=', out ReadOnlySpan<char> left, out ReadOnlySpan<char> right))
{
yield return new IniParameter(left.Trim().ToString(), right.Trim().ToString());
results.Add(new IniParameter(left.Trim().ToString(), right.Trim().ToString()));
}
}
}
return results;
}
/// <summary>

View File

@@ -4,8 +4,10 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Snap.Hutao.Core.Abstraction;
using Snap.Hutao.ViewModel.User;
using Snap.Hutao.Web.Hoyolab;
using Snap.Hutao.Web.Hoyolab.Takumi.Binding;
using Snap.Hutao.Web.Hoyolab.Takumi.GameRecord.DailyNote;
using Snap.Hutao.Web.Request.QueryString;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

View File

@@ -67,7 +67,7 @@ internal sealed partial class DescriptionsParametersDescriptor : ValueConverter<
if (match.Success)
{
int index = int.Parse(match.Groups[1].Value, CultureInfo.CurrentCulture) - 1;
return ParameterFormat.Format($"{{0:{match.Groups[2].Value}}}", paramList[index], CultureInfo.CurrentCulture);
return ParameterFormat.FormatInvariant($"{{0:{match.Groups[2].Value}}}", paramList[index]);
}
else
{

View File

@@ -11,34 +11,29 @@ internal sealed class ParameterFormat : IFormatProvider, ICustomFormatter
{
private static readonly Lazy<ParameterFormat> LazyFormat = new();
/// <summary>
/// 格式化
/// </summary>
/// <param name="str">字符串</param>
/// <param name="param">参数</param>
/// <returns>格式化的字符串</returns>
public static string Format(string str, object param, IFormatProvider? formatProvider = default)
public static string FormatInvariant(string str, object param)
{
return string.Format(LazyFormat.Value, str, param);
}
/// <inheritdoc/>
[SuppressMessage("", "CA1305")]
public string Format(string? fmt, object? arg, IFormatProvider? formatProvider)
{
ReadOnlySpan<char> fmtSpan = fmt;
switch (fmtSpan.Length)
{
case 3: // FnP
return string.Format(formatProvider, $"{{0:P{fmtSpan[1]}}}", arg);
return string.Format($"{{0:P{fmtSpan[1]}}}", arg);
case 2: // Fn
return string.Format(formatProvider, $"{{0:{fmtSpan}}}", arg);
return string.Format($"{{0:{fmtSpan}}}", arg);
case 1: // P I
switch (fmtSpan[0])
{
case 'P':
return string.Format(formatProvider, $"{{0:P0}}", arg);
return string.Format($"{{0:P0}}", arg);
case 'I':
return arg is null ? "0" : ((IConvertible)arg).ToInt32(default).ToString(formatProvider);
return arg is null ? "0" : ((IConvertible)arg).ToInt32(default).ToString();
}
break;

View File

@@ -1851,6 +1851,24 @@ namespace Snap.Hutao.Resource.Localization {
}
}
/// <summary>
/// 查找类似 距上个五星 的本地化字符串。
/// </summary>
internal static string ViewControlStatisticsCardToLastOrangeText {
get {
return ResourceManager.GetString("ViewControlStatisticsCardToLastOrangeText", resourceCulture);
}
}
/// <summary>
/// 查找类似 距上个四星 的本地化字符串。
/// </summary>
internal static string ViewControlStatisticsCardToLastPurpleText {
get {
return ResourceManager.GetString("ViewControlStatisticsCardToLastPurpleText", resourceCulture);
}
}
/// <summary>
/// 查找类似 UP 平均抽数 的本地化字符串。
/// </summary>

View File

@@ -770,6 +770,12 @@
<data name="ViewControlStatisticsCardPurpleText" xml:space="preserve">
<value>四星</value>
</data>
<data name="ViewControlStatisticsCardToLastOrangeText" xml:space="preserve">
<value>距上个五星</value>
</data>
<data name="ViewControlStatisticsCardToLastPurpleText" xml:space="preserve">
<value>距上个四星</value>
</data>
<data name="ViewControlStatisticsCardUpAveragePullText" xml:space="preserve">
<value>UP 平均抽数</value>
</data>

View File

@@ -41,18 +41,18 @@ internal sealed partial class DailyNoteService : IDailyNoteService, IRecipient<U
}
/// <inheritdoc/>
public async ValueTask AddDailyNoteAsync(UserAndUid role)
public async ValueTask AddDailyNoteAsync(UserAndUid userAndUid)
{
string roleUid = role.Uid.Value;
string roleUid = userAndUid.Uid.Value;
if (!dailyNoteDbService.ContainsUid(roleUid))
{
DailyNoteEntry newEntry = DailyNoteEntry.From(role);
DailyNoteEntry newEntry = DailyNoteEntry.From(userAndUid);
Web.Response.Response<WebDailyNote> dailyNoteResponse = await serviceProvider
.GetRequiredService<IOverseaSupportFactory<IGameRecordClient>>()
.Create(PlayerUid.IsOversea(roleUid))
.GetDailyNoteAsync(role)
.GetDailyNoteAsync(userAndUid)
.ConfigureAwait(false);
if (dailyNoteResponse.IsOk())
@@ -63,6 +63,7 @@ internal sealed partial class DailyNoteService : IDailyNoteService, IRecipient<U
newEntry.UserGameRole = userService.GetUserGameRoleByUid(roleUid);
await dailyNoteDbService.AddDailyNoteEntryAsync(newEntry).ConfigureAwait(false);
newEntry.User = userAndUid.User;
await taskContext.SwitchToMainThreadAsync();
entries?.Add(newEntry);
}
@@ -77,7 +78,7 @@ internal sealed partial class DailyNoteService : IDailyNoteService, IRecipient<U
await userService.GetRoleCollectionAsync().ConfigureAwait(false);
await RefreshDailyNotesAsync().ConfigureAwait(false);
List<DailyNoteEntry> entryList = dailyNoteDbService.GetDailyNoteEntryList();
List<DailyNoteEntry> entryList = dailyNoteDbService.GetDailyNoteEntryIncludeUserList();
entryList.ForEach(entry => { entry.UserGameRole = userService.GetUserGameRoleByUid(entry.Uid); });
entries = new(entryList);
}
@@ -98,7 +99,7 @@ internal sealed partial class DailyNoteService : IDailyNoteService, IRecipient<U
if (dailyNoteResponse.IsOk())
{
WebDailyNote dailyNote = dailyNoteResponse.Data!;
WebDailyNote dailyNote = dailyNoteResponse.Data;
// cache
await taskContext.SwitchToMainThreadAsync();

View File

@@ -16,9 +16,9 @@ internal interface IDailyNoteService
/// <summary>
/// 添加实时便笺
/// </summary>
/// <param name="role">角色</param>
/// <param name="userAndUid">角色</param>
/// <returns>任务</returns>
ValueTask AddDailyNoteAsync(UserAndUid role);
ValueTask AddDailyNoteAsync(UserAndUid userAndUid);
/// <summary>
/// 异步获取实时便笺列表

View File

@@ -151,6 +151,7 @@ internal sealed partial class UserService : IUserService
/// <inheritdoc/>
public async ValueTask<bool> RefreshCookieTokenAsync(BindingUser user)
{
// TODO: 提醒其他组件此用户的Cookie已更改
Response<UidCookieToken> cookieTokenResponse = await serviceProvider
.GetRequiredService<IOverseaSupportFactory<IPassportClient>>()
.Create(user.Entity.IsOversea)

View File

@@ -111,6 +111,7 @@
<None Remove="View\Card\LaunchGameCard.xaml" />
<None Remove="View\Control\BaseValueSlider.xaml" />
<None Remove="View\Control\BottomTextControl.xaml" />
<None Remove="View\Control\BottomTextSmallControl.xaml" />
<None Remove="View\Control\DescParamComboBox.xaml" />
<None Remove="View\Control\Elevation.xaml" />
<None Remove="View\Control\HutaoStatisticsCard.xaml" />
@@ -120,14 +121,12 @@
<None Remove="View\Control\LoadingViewSlim.xaml" />
<None Remove="View\Control\SkillPivot.xaml" />
<None Remove="View\Control\StatisticsCard.xaml" />
<None Remove="View\Control\Webview2Viewer.xaml" />
<None Remove="View\Dialog\AchievementArchiveCreateDialog.xaml" />
<None Remove="View\Dialog\AchievementImportDialog.xaml" />
<None Remove="View\Dialog\AdoptCalculatorDialog.xaml" />
<None Remove="View\Dialog\CommunityGameRecordDialog.xaml" />
<None Remove="View\Dialog\CultivateProjectDialog.xaml" />
<None Remove="View\Dialog\CultivatePromotionDeltaDialog.xaml" />
<None Remove="View\Dialog\DailyNoteNotificationDialog.xaml" />
<None Remove="View\Dialog\DailyNoteVerificationDialog.xaml" />
<None Remove="View\Dialog\GachaLogImportDialog.xaml" />
<None Remove="View\Dialog\GachaLogRefreshProgressDialog.xaml" />
<None Remove="View\Dialog\GachaLogUrlDialog.xaml" />
@@ -307,6 +306,18 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Page Update="View\Control\Webview2Viewer.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="View\Control\BottomTextSmallControl.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="GuideWindow.xaml">
<Generator>MSBuild:Compile</Generator>
@@ -387,11 +398,6 @@
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="View\Dialog\CommunityGameRecordDialog.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="View\Dialog\CultivatePromotionDeltaDialog.xaml">
<Generator>MSBuild:Compile</Generator>
@@ -407,21 +413,11 @@
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="View\Dialog\AdoptCalculatorDialog.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="View\Page\WikiWeaponPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="View\Dialog\DailyNoteVerificationDialog.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="View\Dialog\SignInWebViewDialog.xaml">
<Generator>MSBuild:Compile</Generator>

View File

@@ -4,7 +4,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">
<UserControl.Transitions>
<TransitionCollection>
@@ -13,7 +12,7 @@
</UserControl.Transitions>
<WebView2
x:Name="WebView"
Margin="0,0,0,0"
Margin="0"
DefaultBackgroundColor="Transparent"
IsRightTapEnabled="False"/>
</UserControl>
</UserControl>

View File

@@ -2,6 +2,7 @@
// Licensed under the MIT license.
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.Web.WebView2.Core;
using Snap.Hutao.Control;
using Snap.Hutao.Control.Theme;
@@ -17,7 +18,7 @@ namespace Snap.Hutao.View.Control;
/// </summary>
[HighQuality]
[DependencyProperty("Announcement", typeof(Announcement))]
internal sealed partial class AnnouncementContentViewer : Microsoft.UI.Xaml.Controls.UserControl
internal sealed partial class AnnouncementContentViewer : UserControl
{
// apply in dark mode, Dark theme
private const string LightColor1 = "color:rgba(255,255,255,1)";
@@ -84,14 +85,15 @@ internal sealed partial class AnnouncementContentViewer : Microsoft.UI.Xaml.Cont
if (isDarkMode)
{
// TODO: rewrite with Span IndexOfAny
content = content
.Replace(DarkColor5, LightColor5)
.Replace(DarkColor4, LightColor4)
.Replace(DarkColor3, LightColor3)
.Replace(DarkColor2, LightColor2)
.Replace(DarkColor1, LightColor1)
.Replace(DarkAccentColor1, LightAccentColor1)
.Replace(DarkAccentColor2, LightAccentColor2);
.Replace(DarkColor5, LightColor5, StringComparison.Ordinal)
.Replace(DarkColor4, LightColor4, StringComparison.Ordinal)
.Replace(DarkColor3, LightColor3, StringComparison.Ordinal)
.Replace(DarkColor2, LightColor2, StringComparison.Ordinal)
.Replace(DarkColor1, LightColor1, StringComparison.Ordinal)
.Replace(DarkAccentColor2, LightAccentColor2, StringComparison.Ordinal)
.Replace(DarkAccentColor1, LightAccentColor1, StringComparison.Ordinal);
}
string document = $$"""
@@ -128,6 +130,18 @@ internal sealed partial class AnnouncementContentViewer : Microsoft.UI.Xaml.Cont
[GeneratedRegex("style=\".*?vertical-align:middle;\"")]
private static partial Regex StyleRegex();
private void OnLoaded(object sender, RoutedEventArgs e)
{
LoadAnnouncementAsync().SafeForget();
}
private void OnUnloaded(object sender, RoutedEventArgs e)
{
WebView.CoreWebView2.WebMessageReceived -= webMessageReceivedHandler;
Loaded -= loadEventHandler;
Unloaded -= unloadEventHandler;
}
private async ValueTask LoadAnnouncementAsync()
{
try
@@ -150,18 +164,6 @@ internal sealed partial class AnnouncementContentViewer : Microsoft.UI.Xaml.Cont
WebView.NavigateToString(GenerateHtml(Announcement, ActualTheme));
}
private void OnLoaded(object sender, RoutedEventArgs e)
{
LoadAnnouncementAsync().SafeForget();
}
private void OnUnloaded(object sender, RoutedEventArgs e)
{
WebView.CoreWebView2.WebMessageReceived -= webMessageReceivedHandler;
Loaded -= loadEventHandler;
Unloaded -= unloadEventHandler;
}
private void OnWebMessageReceived(CoreWebView2 coreWebView2, CoreWebView2WebMessageReceivedEventArgs args)
{
string url = args.TryGetWebMessageAsString();

View File

@@ -10,12 +10,13 @@
<StackPanel Background="{x:Bind Fill}">
<ContentPresenter Content="{x:Bind TopContent, Mode=OneWay}"/>
<TextBlock
MaxWidth="80"
Margin="0,0,0,2"
HorizontalAlignment="Center"
HorizontalAlignment="Stretch"
HorizontalTextAlignment="Center"
Text="{x:Bind Text, Mode=OneWay}"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap"/>
</StackPanel>
</Border>
</ContentControl>

View File

@@ -15,8 +15,8 @@ namespace Snap.Hutao.View.Control;
[HighQuality]
[ContentProperty(Name = nameof(TopContent))]
[DependencyProperty("Text", typeof(string), "")]
[DependencyProperty("TopContent", typeof(UIElement), default!)]
[DependencyProperty("Fill", typeof(Brush), default!)]
[DependencyProperty("TopContent", typeof(UIElement), default!)]
internal sealed partial class BottomTextControl : ContentControl
{
/// <summary>

View File

@@ -0,0 +1,23 @@
<UserControl
x:Class="Snap.Hutao.View.Control.BottomTextSmallControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Border Style="{StaticResource BorderCardStyle}">
<StackPanel Background="{x:Bind Background, Mode=OneWay}">
<ContentPresenter Content="{x:Bind TopContent, Mode=OneWay}"/>
<TextBlock
HorizontalAlignment="Stretch"
Foreground="{x:Bind Foreground, Mode=OneWay}"
HorizontalTextAlignment="Center"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{x:Bind Text, Mode=OneWay}"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap"/>
</StackPanel>
</Border>
</UserControl>

View File

@@ -0,0 +1,21 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Markup;
using Microsoft.UI.Xaml.Media;
using Windows.UI;
namespace Snap.Hutao.View.Control;
[ContentProperty(Name = nameof(TopContent))]
[DependencyProperty("Text", typeof(string), "")]
[DependencyProperty("TopContent", typeof(UIElement), default!)]
internal sealed partial class BottomTextSmallControl : UserControl
{
public BottomTextSmallControl()
{
this.InitializeComponent();
}
}

View File

@@ -2,7 +2,7 @@
x:Class="Snap.Hutao.View.Control.StatisticsCard"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:CommunityToolkit.WinUI.UI.Converters"
xmlns:cwuc="using:CommunityToolkit.WinUI.UI.Converters"
xmlns:cwucont="using:CommunityToolkit.WinUI.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -21,18 +21,15 @@
<shvconv:Int32ToGradientColorConverter x:Key="Int32ToGradientColorConverter" MaximumValue="{Binding GuaranteeOrangeThreshold}"/>
<DataTemplate x:Key="OrangeListTemplate" d:DataType="shvg:SummaryItem">
<Grid
Margin="0,4,0,0"
Background="Transparent"
Style="{StaticResource BorderGridStyle}">
<Grid Margin="0,4,0,0" Style="{StaticResource BorderGridStyle}">
<ToolTipService.ToolTip>
<TextBlock Text="{Binding TimeFormatted}"/>
</ToolTipService.ToolTip>
<ProgressBar
MinHeight="32"
Background="{ThemeResource CardBackgroundFillColorSecondaryBrush}"
CornerRadius="{StaticResource CompatCornerRadius}"
MinHeight="40"
Background="Transparent"
CornerRadius="{StaticResource ControlCornerRadius}"
Maximum="{Binding GuaranteeOrangeThreshold}"
Opacity="{StaticResource LargeBackgroundProgressBarOpacity}"
Value="{Binding LastPull}">
@@ -43,11 +40,11 @@
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
<shci:CachedImage
shvh:FrameworkElementHelper.SquareLength="32"
shvh:FrameworkElementHelper.SquareLength="40"
CornerRadius="{ThemeResource ControlCornerRadius}"
Source="{Binding Icon}"/>
<TextBlock
Margin="8,0,0,0"
Margin="16,0,0,0"
VerticalAlignment="Center"
Text="{Binding Name}">
<TextBlock.Foreground>
@@ -60,13 +57,13 @@
<TextBlock
Margin="0,0,8,0"
VerticalAlignment="Center"
Foreground="#FF0063FF"
Foreground="{StaticResource GuaranteePullBrush}"
Text="{shcm:ResourceString Name=ViewControlStatisticsCardGuaranteeText}"
Visibility="{Binding IsGuarantee, Converter={StaticResource BoolToVisibilityConverter}}"/>
<TextBlock
Margin="0,0,8,0"
VerticalAlignment="Center"
Foreground="#FFFFA400"
Foreground="{StaticResource UpPullBrush}"
Text="{shcm:ResourceString Name=ViewControlStatisticsCardUpText}"
Visibility="{Binding IsUp, Converter={StaticResource BoolToVisibilityConverter}}"/>
@@ -82,35 +79,26 @@
</Grid>
</DataTemplate>
<converters:BoolToObjectConverter
<cwuc:BoolToObjectConverter
x:Key="BoolToBrushConverter"
FalseValue="{ThemeResource SystemFillColorCriticalBackgroundBrush}"
TrueValue="{ThemeResource CardBackgroundFillColorDefaultBrush}"/>
<DataTemplate x:Key="OrangeGridTemplate" d:DataType="shvg:SummaryItem">
<Border
Width="40"
Margin="0,4,4,0"
Background="{Binding IsUp, Converter={StaticResource BoolToBrushConverter}}"
Style="{StaticResource BorderCardStyle}"
ToolTipService.ToolTip="{Binding TimeFormatted}">
<StackPanel>
<shvcont:BottomTextSmallControl Text="{Binding LastPull}">
<shvcont:BottomTextSmallControl.Foreground>
<SolidColorBrush Color="{Binding Color}"/>
</shvcont:BottomTextSmallControl.Foreground>
<shvcont:ItemIcon
Width="40"
Height="40"
shvh:FrameworkElementHelper.SquareLength="40"
Icon="{Binding Icon}"
Quality="QUALITY_ORANGE"/>
<TextBlock
HorizontalTextAlignment="Center"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding LastPull}"
TextTrimming="None"
TextWrapping="NoWrap">
<TextBlock.Foreground>
<SolidColorBrush Color="{Binding Color}"/>
</TextBlock.Foreground>
</TextBlock>
</StackPanel>
Quality="{Binding Quality}"/>
</shvcont:BottomTextSmallControl>
</Border>
</DataTemplate>
</UserControl.Resources>
@@ -157,15 +145,17 @@
Margin="0,0,6,0"
VerticalAlignment="Center"
FontSize="20"
Text="{Binding TotalCount}"
Visibility="{Binding ElementName=DetailExpander, Path=IsExpanded, Converter={StaticResource BoolToVisibilityRevertConverter}}"/>
Text="{Binding TotalCountFormatted}"
Visibility="{x:Bind DetailExpander.IsExpanded, Converter={StaticResource BoolToVisibilityRevertConverter}, Mode=OneWay}"/>
<shcp:PanelSelector
x:Name="ItemsPanelSelector"
Margin="6,0,0,0"
Current="Grid"/>
Current="Grid"
Visibility="{x:Bind DetailExpander.IsExpanded, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}"/>
</StackPanel>
</Grid>
</Expander.Header>
<StackPanel>
<StackPanel Grid.Row="1" Margin="0,0,0,12">
<StackPanel Orientation="Horizontal">
@@ -185,167 +175,163 @@
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Style="{StaticResource BorderCardStyle}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ProgressRing
Grid.Column="0"
Width="40"
Height="40"
Margin="4"
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
Foreground="{StaticResource OrangeBrush}"
IsIndeterminate="False"
Maximum="{Binding GuaranteeOrangeThreshold}"
Value="{Binding LastOrangePull}"/>
<TextBlock
Grid.Column="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="{StaticResource OrangeBrush}"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding LastOrangePull}"/>
<TextBlock
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="{StaticResource OrangeBrush}"
Style="{StaticResource BaseTextBlockStyle}"
Text="{shcm:ResourceString Name=ViewControlStatisticsCardOrangeText}"/>
</Grid>
</Border>
<Border Grid.Column="1" Style="{StaticResource BorderCardStyle}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ProgressRing
Grid.Column="0"
Width="40"
Height="40"
Margin="4"
Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
Foreground="{StaticResource PurpleBrush}"
IsIndeterminate="False"
Maximum="{Binding GuaranteePurpleThreshold}"
Value="{Binding LastPurplePull}"/>
<TextBlock
Grid.Column="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="{StaticResource PurpleBrush}"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding LastPurplePull}"/>
<TextBlock
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="{StaticResource PurpleBrush}"
Style="{StaticResource BaseTextBlockStyle}"
Text="{shcm:ResourceString Name=ViewControlStatisticsCardPurpleText}"/>
</Grid>
</Border>
<Grid Grid.Column="0" Style="{StaticResource BorderGridStyle}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ProgressBar
Grid.ColumnSpan="2"
MinHeight="32"
Background="Transparent"
Foreground="{StaticResource OrangeBrush}"
Maximum="{Binding GuaranteeOrangeThreshold}"
Opacity="{StaticResource LargeBackgroundProgressBarOpacity}"
Value="{Binding LastOrangePull}"/>
<TextBlock
Grid.Column="0"
Margin="6,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="{StaticResource OrangeBrush}"
Style="{StaticResource BaseTextBlockStyle}"
Text="{shcm:ResourceString Name=ViewControlStatisticsCardToLastOrangeText}"/>
<TextBlock
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="{StaticResource OrangeBrush}"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding LastOrangePull}"/>
</Grid>
<Grid Grid.Column="1" Style="{StaticResource BorderGridStyle}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ProgressBar
Grid.ColumnSpan="2"
MinHeight="32"
Background="Transparent"
Foreground="{StaticResource PurpleBrush}"
Maximum="{Binding GuaranteePurpleThreshold}"
Opacity="{StaticResource LargeBackgroundProgressBarOpacity}"
Value="{Binding LastPurplePull}"/>
<TextBlock
Grid.Column="0"
Margin="6,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="{StaticResource PurpleBrush}"
Style="{StaticResource BaseTextBlockStyle}"
Text="{shcm:ResourceString Name=ViewControlStatisticsCardToLastPurpleText}"/>
<TextBlock
Grid.Column="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="{StaticResource PurpleBrush}"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding LastPurplePull}"/>
</Grid>
</Grid>
<StackPanel Margin="0,8,0,0" Orientation="Horizontal">
<TextBlock
HorizontalAlignment="Left"
Opacity="0.6"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding FromFormatted}"/>
<TextBlock
HorizontalAlignment="Left"
VerticalAlignment="Center"
Opacity="0.6"
Style="{StaticResource CaptionTextBlockStyle}"
Text="-"/>
<TextBlock
HorizontalAlignment="Left"
Opacity="0.6"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding ToFormatted}"/>
</StackPanel>
</StackPanel>
<MenuFlyoutSeparator Margin="-12,0"/>
<StackPanel Margin="0,12,0,0">
<Grid>
<TextBlock
Foreground="{StaticResource OrangeBrush}"
Style="{StaticResource BodyTextBlockStyle}"
Text="{shcm:ResourceString Name=ViewControlStatisticsCardOrangeText}"/>
<TextBlock
HorizontalAlignment="Right"
FontFamily="{StaticResource CascadiaMonoAndMiSans}"
Foreground="{StaticResource OrangeBrush}"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding TotalOrangeFormatted}"/>
</Grid>
<Grid Margin="0,2,0,0">
<TextBlock
Foreground="{StaticResource PurpleBrush}"
Style="{StaticResource BodyTextBlockStyle}"
Text="{shcm:ResourceString Name=ViewControlStatisticsCardPurpleText}"/>
<TextBlock
HorizontalAlignment="Right"
FontFamily="{StaticResource CascadiaMonoAndMiSans}"
Foreground="{StaticResource PurpleBrush}"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding TotalPurpleFormatted}"/>
</Grid>
<Grid Margin="0,2,0,0">
<TextBlock
Foreground="{StaticResource BlueBrush}"
Style="{StaticResource BodyTextBlockStyle}"
Text="{shcm:ResourceString Name=ViewControlStatisticsCardBlueText}"/>
<TextBlock
HorizontalAlignment="Right"
FontFamily="{StaticResource CascadiaMonoAndMiSans}"
Foreground="{StaticResource BlueBrush}"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding TotalBlueFormatted}"/>
</Grid>
<FlipView
Name="StatisticsFilpView"
Height="74"
Margin="-16,0"
VerticalAlignment="Top"
Background="Transparent">
<Grid Margin="0,2,0,0">
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{shcm:ResourceString Name=ViewControlStatisticsCardOrangeAveragePullText}"/>
<TextBlock
HorizontalAlignment="Right"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding AverageOrangePullFormatted}"/>
</Grid>
<Grid Margin="0,2,0,0">
<TextBlock/>
<TextBlock
Style="{StaticResource BodyTextBlockStyle}"
Text="{shcm:ResourceString Name=ViewControlStatisticsCardUpAveragePullText}"
Visibility="{x:Bind ShowUpPull, Converter={StaticResource BoolToVisibilityConverter}}"/>
<TextBlock
HorizontalAlignment="Right"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding AverageUpOrangePullFormatted}"
Visibility="{x:Bind ShowUpPull, Converter={StaticResource BoolToVisibilityConverter}}"/>
</Grid>
<Grid Margin="0,2,0,0">
<TextBlock
HorizontalAlignment="Left"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding MaxOrangePullFormatted}"/>
<TextBlock
HorizontalAlignment="Right"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding MinOrangePullFormatted}"/>
</Grid>
<StackPanel Margin="0,2,0,0" Visibility="{Binding IsPredictPullAvailable, Converter={StaticResource BoolToVisibilityConverter}}">
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding PredictedPullLeftToOrangeFormatted}"/>
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding ProbabilityOfNextPullIsOrangeFormatted}"/>
</StackPanel>
</StackPanel>
<MenuFlyoutSeparator Margin="-12,12,-12,0"/>
<FlipViewItem>
<StackPanel Padding="16,12" Spacing="2">
<Grid>
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{shcm:ResourceString Name=ViewControlStatisticsCardOrangeAveragePullText}"/>
<TextBlock
HorizontalAlignment="Right"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding AverageOrangePullFormatted}"/>
</Grid>
<Grid>
<TextBlock/>
<TextBlock
Style="{StaticResource BodyTextBlockStyle}"
Text="{shcm:ResourceString Name=ViewControlStatisticsCardUpAveragePullText}"
Visibility="{x:Bind ShowUpPull, Converter={StaticResource BoolToVisibilityConverter}}"/>
<TextBlock
HorizontalAlignment="Right"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding AverageUpOrangePullFormatted}"
Visibility="{x:Bind ShowUpPull, Converter={StaticResource BoolToVisibilityConverter}}"/>
</Grid>
<Grid>
<TextBlock
HorizontalAlignment="Left"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding MaxOrangePullFormatted}"/>
<TextBlock
HorizontalAlignment="Right"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding MinOrangePullFormatted}"/>
</Grid>
</StackPanel>
</FlipViewItem>
<FlipViewItem Visibility="{Binding IsPredictPullAvailable, Converter={StaticResource BoolToVisibilityConverter}}">
<StackPanel Margin="16,12" Spacing="2">
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding PredictedPullLeftToOrangeFormatted}"/>
<TextBlock Style="{StaticResource BodyTextBlockStyle}" Text="{Binding ProbabilityOfNextPullIsOrangeFormatted}"/>
</StackPanel>
</FlipViewItem>
<FlipViewItem>
<StackPanel Padding="16,12" Spacing="2">
<Grid>
<TextBlock
Foreground="{StaticResource OrangeBrush}"
Style="{StaticResource BodyTextBlockStyle}"
Text="{shcm:ResourceString Name=ViewControlStatisticsCardOrangeText}"/>
<TextBlock
HorizontalAlignment="Right"
FontFamily="{StaticResource CascadiaMonoAndMiSans}"
Foreground="{StaticResource OrangeBrush}"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding TotalOrangeFormatted}"/>
</Grid>
<Grid>
<TextBlock
Foreground="{StaticResource PurpleBrush}"
Style="{StaticResource BodyTextBlockStyle}"
Text="{shcm:ResourceString Name=ViewControlStatisticsCardPurpleText}"/>
<TextBlock
HorizontalAlignment="Right"
FontFamily="{StaticResource CascadiaMonoAndMiSans}"
Foreground="{StaticResource PurpleBrush}"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding TotalPurpleFormatted}"/>
</Grid>
<Grid>
<TextBlock
Foreground="{StaticResource BlueBrush}"
Style="{StaticResource BodyTextBlockStyle}"
Text="{shcm:ResourceString Name=ViewControlStatisticsCardBlueText}"/>
<TextBlock
HorizontalAlignment="Right"
FontFamily="{StaticResource CascadiaMonoAndMiSans}"
Foreground="{StaticResource BlueBrush}"
Style="{StaticResource BodyTextBlockStyle}"
Text="{Binding TotalBlueFormatted}"/>
</Grid>
</StackPanel>
</FlipViewItem>
</FlipView>
<PipsPager
Height="16"
Margin="0,-4,0,0"
HorizontalAlignment="Center"
NumberOfPages="{x:Bind StatisticsFilpView.Items.Count}"
SelectedPageIndex="{x:Bind StatisticsFilpView.SelectedIndex, Mode=TwoWay}"/>
<MenuFlyoutSeparator Margin="-12,0,-12,0"/>
</StackPanel>
</Expander>
<ScrollViewer
Grid.Row="2"
@@ -353,7 +339,9 @@
VerticalScrollBarVisibility="Hidden">
<cwucont:SwitchPresenter Value="{Binding ElementName=ItemsPanelSelector, Path=Current}">
<cwucont:SwitchPresenter.ContentTransitions>
<ContentThemeTransition/>
<TransitionCollection>
<ContentThemeTransition/>
</TransitionCollection>
</cwucont:SwitchPresenter.ContentTransitions>
<cwucont:Case Value="List">
<ItemsControl ItemTemplate="{StaticResource OrangeListTemplate}" ItemsSource="{Binding OrangeList}"/>
@@ -362,16 +350,8 @@
<ItemsControl
Margin="0,0,-4,0"
ItemTemplate="{StaticResource OrangeGridTemplate}"
ItemsSource="{Binding OrangeList}">
<ItemsControl.Transitions>
<ReorderThemeTransition/>
</ItemsControl.Transitions>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<cwucont:WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
ItemsPanel="{StaticResource WrapPanelTemplate}"
ItemsSource="{Binding OrangeList}"/>
</cwucont:Case>
</cwucont:SwitchPresenter>
</ScrollViewer>

View File

@@ -0,0 +1,18 @@
<UserControl
x:Class="Snap.Hutao.View.Control.Webview2Viewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Snap.Hutao.View.Control"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<UserControl.Transitions>
<TransitionCollection>
<EntranceThemeTransition/>
</TransitionCollection>
</UserControl.Transitions>
<WebView2
x:Name="WebView"
Margin="0"
DefaultBackgroundColor="Transparent"/>
</UserControl>

View File

@@ -0,0 +1,90 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.Web.WebView2.Core;
using Snap.Hutao.Service.Notification;
using Snap.Hutao.Service.User;
using Snap.Hutao.ViewModel.User;
using Snap.Hutao.Web.Bridge;
namespace Snap.Hutao.View.Control;
[DependencyProperty("Source", typeof(string), default(string)!, nameof(OnSourceChanged))]
[DependencyProperty("User", typeof(User))]
internal partial class Webview2Viewer : UserControl
{
private readonly IServiceProvider serviceProvider;
private readonly RoutedEventHandler loadEventHandler;
private readonly RoutedEventHandler unloadEventHandler;
private MiHoYoJSInterface? jsInterface;
private bool isInitialized;
public Webview2Viewer()
{
InitializeComponent();
serviceProvider = Ioc.Default;
loadEventHandler = OnLoaded;
unloadEventHandler = OnUnloaded;
Loaded += loadEventHandler;
Unloaded += unloadEventHandler;
}
private static void OnSourceChanged(DependencyObject dp, DependencyPropertyChangedEventArgs e)
{
Webview2Viewer viewer = (Webview2Viewer)dp;
if (viewer.isInitialized)
{
viewer.RefreshWebview2Content();
}
}
private void OnLoaded(object sender, RoutedEventArgs e)
{
InitializeAsync().SafeForget();
}
private void OnUnloaded(object sender, RoutedEventArgs e)
{
jsInterface = null;
Loaded -= loadEventHandler;
Unloaded -= unloadEventHandler;
}
private async ValueTask InitializeAsync()
{
await WebView.EnsureCoreWebView2Async();
RefreshWebview2Content();
}
private void RefreshWebview2Content()
{
if (User is null)
{
IUserService userService = serviceProvider.GetRequiredService<IUserService>();
User ??= userService.Current;
if (User is null)
{
return;
}
}
CoreWebView2 coreWebView2 = WebView.CoreWebView2;
if (UserAndUid.TryFromUser(User, out UserAndUid? userAndUid) && !string.IsNullOrEmpty(Source))
{
coreWebView2.SetCookie(User.CookieToken, User.LToken, User.SToken).SetMobileUserAgent();
jsInterface = serviceProvider.CreateInstance<MiHoYoJSInterface>(coreWebView2, userAndUid);
coreWebView2.Navigate(Source);
}
else
{
serviceProvider.GetRequiredService<IInfoBarService>().Warning(SH.MustSelectUserAndUid);
}
isInitialized = true;
}
}

View File

@@ -3,6 +3,7 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
using Snap.Hutao.Core.ExceptionService;
namespace Snap.Hutao.View.Converter;
@@ -15,12 +16,12 @@ internal sealed class Int32ToVisibilityConverter : IValueConverter
/// <inheritdoc/>
public object Convert(object value, Type targetType, object parameter, string language)
{
return value != null && ((int)value != 0) ? Visibility.Visible : Visibility.Collapsed;
return value is not 0 ? Visibility.Visible : Visibility.Collapsed;
}
/// <inheritdoc/>
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
throw ThrowHelper.NotSupported();
}
}

View File

@@ -3,6 +3,7 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
using Snap.Hutao.Core.ExceptionService;
namespace Snap.Hutao.View.Converter;
@@ -15,12 +16,12 @@ internal sealed class Int32ToVisibilityRevertConverter : IValueConverter
/// <inheritdoc/>
public object Convert(object value, Type targetType, object parameter, string language)
{
return value != null && (int)value == 0 ? Visibility.Visible : Visibility.Collapsed;
return value is null or 0 ? Visibility.Visible : Visibility.Collapsed;
}
/// <inheritdoc/>
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
throw ThrowHelper.NotSupported();
}
}

View File

@@ -3,6 +3,7 @@
using Microsoft.UI.Xaml;
using Snap.Hutao.Control;
using Snap.Hutao.Control.Panel;
namespace Snap.Hutao.View.Converter;
@@ -18,8 +19,8 @@ internal sealed partial class PanelSelectorModeConverter : DependencyValueConver
{
return from switch
{
"List" => ListValue,
"Grid" => GridValue,
PanelSelector.List => ListValue,
PanelSelector.Grid => GridValue,
_ => default!,
};
}

View File

@@ -29,7 +29,7 @@ internal sealed partial class AchievementArchiveCreateDialog : ContentDialog
/// 获取输入的字符串
/// </summary>
/// <returns>输入的结果</returns>
public async Task<ValueResult<bool, string>> GetInputAsync()
public async ValueTask<ValueResult<bool, string>> GetInputAsync()
{
await taskContext.SwitchToMainThreadAsync();
ContentDialogResult result = await ShowAsync();

View File

@@ -36,7 +36,7 @@ internal sealed partial class AchievementImportDialog : ContentDialog
/// 异步获取导入选项
/// </summary>
/// <returns>导入选项</returns>
public async Task<ValueResult<bool, ImportStrategy>> GetImportStrategyAsync()
public async ValueTask<ValueResult<bool, ImportStrategy>> GetImportStrategyAsync()
{
await taskContext.SwitchToMainThreadAsync();
ContentDialogResult result = await ShowAsync();

View File

@@ -1,17 +0,0 @@
<ContentDialog
x:Class="Snap.Hutao.View.Dialog.AdoptCalculatorDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Closed="OnContentDialogClosed"
Style="{StaticResource WebView2ContentDialogStyle}"
mc:Ignorable="d">
<Grid Loaded="OnGridLoaded">
<WebView2
Name="WebView"
Width="380"
Height="500"
AllowFocusOnInteraction="False"/>
</Grid>
</ContentDialog>

View File

@@ -1,71 +0,0 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.Web.WebView2.Core;
using Snap.Hutao.Service.User;
using Snap.Hutao.ViewModel.User;
using Snap.Hutao.Web.Bridge;
namespace Snap.Hutao.View.Dialog;
/// <summary>
/// 养成计算器对话框
/// </summary>
[HighQuality]
internal sealed partial class AdoptCalculatorDialog : ContentDialog
{
private readonly ITaskContext taskContext;
private readonly IServiceScope scope;
private MiHoYoJSInterface? jsInterface;
/// <summary>
/// 构造一个新的养成计算器对话框
/// </summary>
/// <param name="serviceProvider">服务提供器</param>
public AdoptCalculatorDialog(IServiceProvider serviceProvider)
{
InitializeComponent();
XamlRoot = serviceProvider.GetRequiredService<MainWindow>().Content.XamlRoot;
taskContext = serviceProvider.GetRequiredService<ITaskContext>();
scope = serviceProvider.CreateScope();
}
private void OnGridLoaded(object sender, RoutedEventArgs e)
{
InitializeAsync().SafeForget();
}
private async Task InitializeAsync()
{
await WebView.EnsureCoreWebView2Async();
CoreWebView2 coreWebView2 = WebView.CoreWebView2;
IUserService userService = scope.ServiceProvider.GetRequiredService<IUserService>();
User? user = userService.Current;
if (user == null)
{
return;
}
coreWebView2.SetCookie(user.CookieToken, user.LToken, null).SetMobileUserAgent();
jsInterface = new(scope.ServiceProvider, coreWebView2);
jsInterface.ClosePageRequested += OnClosePageRequested;
coreWebView2.Navigate($"http://webstatic.mihoyo.com/ys/event/e20200923adopt_calculator/index.html?bbs_presentation_style=fullscreen&bbs_auth_required=true&&utm_source=bbs&utm_medium=mys&utm_campaign=GameRecord");
}
private void OnClosePageRequested()
{
taskContext.InvokeOnMainThread(Hide);
}
private void OnContentDialogClosed(ContentDialog sender, ContentDialogClosedEventArgs args)
{
jsInterface = null;
scope.Dispose();
}
}

View File

@@ -1,16 +0,0 @@
<ContentDialog
x:Class="Snap.Hutao.View.Dialog.CommunityGameRecordDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Closed="OnContentDialogClosed"
Style="{StaticResource WebView2ContentDialogStyle}"
mc:Ignorable="d">
<Grid Loaded="OnGridLoaded">
<WebView2
Name="WebView"
Width="360"
Height="580"/>
</Grid>
</ContentDialog>

View File

@@ -1,69 +0,0 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.Web.WebView2.Core;
using Snap.Hutao.Service.User;
using Snap.Hutao.ViewModel.User;
using Snap.Hutao.Web.Bridge;
namespace Snap.Hutao.View.Dialog;
/// <summary>
/// 社区游戏记录对话框
/// </summary>
[HighQuality]
internal sealed partial class CommunityGameRecordDialog : ContentDialog
{
private readonly ITaskContext taskContext;
private readonly IServiceScope scope;
private MiHoYoJSInterface? jsInterface;
/// <summary>
/// 构造一个新的社区游戏记录对话框
/// </summary>
/// <param name="serviceProvider">服务提供器</param>
public CommunityGameRecordDialog(IServiceProvider serviceProvider)
{
InitializeComponent();
XamlRoot = serviceProvider.GetRequiredService<MainWindow>().Content.XamlRoot;
taskContext = serviceProvider.GetRequiredService<ITaskContext>();
scope = serviceProvider.CreateScope();
}
private void OnGridLoaded(object sender, RoutedEventArgs e)
{
InitializeAsync().SafeForget();
}
private async Task InitializeAsync()
{
await WebView.EnsureCoreWebView2Async();
CoreWebView2 coreWebView2 = WebView.CoreWebView2;
User? user = scope.ServiceProvider.GetRequiredService<IUserService>().Current;
if (user == null)
{
return;
}
coreWebView2.SetCookie(user.CookieToken, user.LToken, null).SetMobileUserAgent();
jsInterface = new(scope.ServiceProvider, coreWebView2);
jsInterface.ClosePageRequested += OnClosePageRequested;
coreWebView2.Navigate("https://webstatic.mihoyo.com/app/community-game-records/index.html");
}
private void OnClosePageRequested()
{
taskContext.InvokeOnMainThread(Hide);
}
private void OnContentDialogClosed(ContentDialog sender, ContentDialogClosedEventArgs args)
{
jsInterface = null;
scope.Dispose();
}
}

View File

@@ -14,12 +14,13 @@
<StackPanel>
<TextBox
x:Name="InputText"
VerticalAlignment="Top"
PlaceholderText="{shcm:ResourceString Name=ViewDialogCultivateProjectInputPlaceholder}"/>
PlaceholderText="{shcm:ResourceString Name=ViewDialogCultivateProjectInputPlaceholder}"
Text="{x:Bind Text, Mode=TwoWay}"/>
<CheckBox
x:Name="AttachUidBox"
Margin="0,8,0,0"
Content="{shcm:ResourceString Name=ViewDialogCultivateProjectAttachUid}"/>
Content="{shcm:ResourceString Name=ViewDialogCultivateProjectAttachUid}"
IsChecked="{x:Bind IsUidAttached, Mode=TwoWay}"
Visibility="Collapsed"/>
</StackPanel>
</ContentDialog>

View File

@@ -11,6 +11,8 @@ namespace Snap.Hutao.View.Dialog;
/// 养成计划对话框
/// </summary>
[HighQuality]
[DependencyProperty("Text", typeof(string))]
[DependencyProperty("IsUidAttached", typeof(bool))]
internal sealed partial class CultivateProjectDialog : ContentDialog
{
private readonly ITaskContext taskContext;
@@ -37,14 +39,13 @@ internal sealed partial class CultivateProjectDialog : ContentDialog
ContentDialogResult result = await ShowAsync();
if (result == ContentDialogResult.Primary)
{
string text = InputText.Text;
string? uid = AttachUidBox.IsChecked == true
string? uid = IsUidAttached
? Ioc.Default.GetRequiredService<IUserService>().Current?.SelectedUserGameRole?.GameUid
: null;
return new(true, CultivateProject.From(text, uid));
return new(true, CultivateProject.From(Text, uid));
}
return new(false, null!);
return new(false, default!);
}
}

View File

@@ -52,13 +52,13 @@ internal sealed partial class CultivatePromotionDeltaDialog : ContentDialog
AvatarId = Avatar?.AvatarId ?? 0,
AvatarLevelCurrent = Avatar?.LevelCurrent ?? 0,
AvatarLevelTarget = Avatar?.LevelTarget ?? 0,
SkillList = Avatar?.Skills.Select(s => new PromotionDelta()
SkillList = Avatar?.Skills.SelectList(s => new PromotionDelta()
{
Id = s.GroupId,
LevelCurrent = s.LevelCurrent,
LevelTarget = s.LevelTarget,
}),
Weapon = Weapon == null ? null : new PromotionDelta()
Weapon = Weapon is null ? null : new PromotionDelta()
{
Id = Weapon.WeaponId,
LevelCurrent = Weapon.LevelCurrent,
@@ -70,7 +70,7 @@ internal sealed partial class CultivatePromotionDeltaDialog : ContentDialog
}
else
{
return new(false, null!);
return new(false, default!);
}
}
}

View File

@@ -1,21 +0,0 @@
<ContentDialog
x:Class="Snap.Hutao.View.Dialog.DailyNoteVerificationDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:shcm="using:Snap.Hutao.Control.Markup"
Closed="OnContentDialogClosed"
DefaultButton="Primary"
PrimaryButtonText="{shcm:ResourceString Name=ContentDialogCompletePrimaryButtonText}"
Style="{StaticResource WebView2ContentDialogStyle}"
mc:Ignorable="d">
<Grid Loaded="OnGridLoaded">
<WebView2
Name="WebView"
Width="380"
Height="448"
AllowFocusOnInteraction="False"
DefaultBackgroundColor="Transparent"/>
</Grid>
</ContentDialog>

View File

@@ -1,75 +0,0 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.Web.WebView2.Core;
using Snap.Hutao.ViewModel.User;
using Snap.Hutao.Web.Bridge;
using Snap.Hutao.Web.Request.QueryString;
namespace Snap.Hutao.View.Dialog;
/// <summary>
/// 实时便笺验证对话框
/// </summary>
[HighQuality]
[SuppressMessage("", "CA1001")]
internal sealed partial class DailyNoteVerificationDialog : ContentDialog
{
private readonly ITaskContext taskContext;
private readonly IServiceScope scope;
private readonly UserAndUid userAndUid;
private MiHoYoJSInterface? jsInterface;
/// <summary>
/// 构造一个新的实时便笺验证对话框
/// </summary>
/// <param name="serviceProvider">服务提供器</param>
/// <param name="userAndUid">用户与角色</param>
public DailyNoteVerificationDialog(IServiceProvider serviceProvider, UserAndUid userAndUid)
{
InitializeComponent();
XamlRoot = serviceProvider.GetRequiredService<MainWindow>().Content.XamlRoot;
taskContext = serviceProvider.GetRequiredService<ITaskContext>();
scope = serviceProvider.CreateScope();
this.userAndUid = userAndUid;
}
private void OnGridLoaded(object sender, RoutedEventArgs e)
{
InitializeAsync().SafeForget();
}
private async Task InitializeAsync()
{
await WebView.EnsureCoreWebView2Async();
CoreWebView2 coreWebView2 = WebView.CoreWebView2;
Model.Entity.User user = userAndUid.User;
coreWebView2.SetCookie(user.CookieToken, user.LToken, null).SetMobileUserAgent();
jsInterface = new(scope.ServiceProvider, coreWebView2);
jsInterface.ClosePageRequested += OnClosePageRequested;
QueryString query = userAndUid.Uid.ToQueryString();
coreWebView2.Navigate($"https://webstatic.mihoyo.com/app/community-game-records/index.html?bbs_presentation_style=fullscreen#/ys/daily/?{query}");
}
private void OnClosePageRequested()
{
taskContext.InvokeOnMainThread(Hide);
}
private void OnContentDialogClosed(ContentDialog sender, ContentDialogClosedEventArgs args)
{
if (jsInterface != null)
{
jsInterface!.ClosePageRequested -= OnClosePageRequested;
jsInterface = null;
}
scope.Dispose();
}
}

View File

@@ -41,23 +41,20 @@ internal sealed partial class SignInWebViewDialog : ContentDialog
await WebView.EnsureCoreWebView2Async();
CoreWebView2 coreWebView2 = WebView.CoreWebView2;
User? user = scope.ServiceProvider.GetRequiredService<IUserService>().Current;
if (user == null)
if (UserAndUid.TryFromUser(user, out UserAndUid? userAndUid))
{
return;
}
if (user.Entity.IsOversea)
{
coreWebView2.SetCookie(user.CookieToken, user.LToken, null, true).SetMobileOverseaUserAgent();
jsInterface = new SignInJSInterfaceOversea(coreWebView2, scope.ServiceProvider);
coreWebView2.Navigate("https://act.hoyolab.com/ys/event/signin-sea-v3/index.html?act_id=e202102251931481");
}
else
{
coreWebView2.SetCookie(user.CookieToken, user.LToken, null, false).SetMobileUserAgent();
jsInterface = new SignInJsInterface(coreWebView2, scope.ServiceProvider);
coreWebView2.Navigate("https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?act_id=e202009291139501");
if (user.Entity.IsOversea)
{
coreWebView2.SetCookie(user.CookieToken, user.LToken, null, true).SetMobileOverseaUserAgent();
jsInterface = new SignInJSInterfaceOversea(coreWebView2, scope.ServiceProvider, userAndUid);
coreWebView2.Navigate("https://act.hoyolab.com/ys/event/signin-sea-v3/index.html?act_id=e202102251931481");
}
else
{
coreWebView2.SetCookie(user.CookieToken, user.LToken, null, false).SetMobileUserAgent();
jsInterface = new SignInJsInterface(coreWebView2, scope.ServiceProvider, userAndUid);
coreWebView2.Navigate("https://webstatic.mihoyo.com/bbs/event/signin-ys/index.html?act_id=e202009291139501");
}
}
}

View File

@@ -8,7 +8,7 @@ using Snap.Hutao.Control;
namespace Snap.Hutao.View.Helper;
[SuppressMessage("", "SH001")]
[DependencyProperty("SquareLength", typeof(double), 0D, nameof(OnSquareLengthChanged), IsAttached = true, AttachedType = typeof(Microsoft.UI.Xaml.Controls.Control))]
[DependencyProperty("SquareLength", typeof(double), 0D, nameof(OnSquareLengthChanged), IsAttached = true, AttachedType = typeof(Microsoft.UI.Xaml.FrameworkElement))]
public sealed partial class FrameworkElementHelper
{
private static void OnSquareLengthChanged(DependencyObject dp, DependencyPropertyChangedEventArgs e)

View File

@@ -14,7 +14,9 @@
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
xmlns:shci="using:Snap.Hutao.Control.Image"
xmlns:shcm="using:Snap.Hutao.Control.Markup"
xmlns:shvc="using:Snap.Hutao.View.Control"
xmlns:shvd="using:Snap.Hutao.ViewModel.DailyNote"
xmlns:shvh="using:Snap.Hutao.View.Helper"
d:DataContext="{d:DesignInstance shvd:DailyNoteViewModel}"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">
@@ -34,11 +36,34 @@
</Grid.RowDefinitions>
<CommandBar Background="{ThemeResource CardBackgroundFillColorDefaultBrush}" DefaultLabelPosition="Right">
<CommandBar.Content>
<Button Margin="12,8,0,0" Content="{shcm:ResourceString Name=ViewPageDailyNoteVerify}">
<mxi:Interaction.Behaviors>
<mxic:EventTriggerBehavior EventName="Click">
<shcb:OpenAttachedFlyoutAction/>
</mxic:EventTriggerBehavior>
</mxi:Interaction.Behaviors>
<FlyoutBase.AttachedFlyout>
<Flyout
LightDismissOverlayMode="On"
Placement="Full"
ShowMode="Standard">
<Flyout.FlyoutPresenterStyle>
<Style TargetType="FlyoutPresenter">
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderBrush" Value="{ThemeResource CardStrokeColorDefaultBrush}"/>
</Style>
</Flyout.FlyoutPresenterStyle>
<shvc:Webview2Viewer Source="{Binding VerifyUrl, Mode=OneWay}"/>
</Flyout>
</FlyoutBase.AttachedFlyout>
</Button>
</CommandBar.Content>
<AppBarButton
Command="{Binding RefreshCommand}"
Icon="{shcm:FontIcon Glyph=&#xE72C;}"
Icon="{shcm:FontIcon Glyph={StaticResource FontIconContentRefresh}}"
Label="{shcm:ResourceString Name=ViewPageDailyNoteRefresh}"/>
<AppBarButton Icon="{shcm:FontIcon Glyph=&#xE710;}" Label="{shcm:ResourceString Name=ViewPageDailyNoteAddEntry}">
<AppBarButton Icon="{shcm:FontIcon Glyph={StaticResource FontIconContentAdd}}" Label="{shcm:ResourceString Name=ViewPageDailyNoteAddEntry}">
<AppBarButton.Flyout>
<Flyout LightDismissOverlayMode="On" Placement="Bottom">
<Flyout.FlyoutPresenterStyle>
@@ -78,11 +103,7 @@
</Flyout>
</AppBarButton.Flyout>
</AppBarButton>
<AppBarButton
Command="{Binding DailyNoteVerificationCommand}"
Icon="{shcm:FontIcon Glyph=&#xE9D5;}"
Label="{shcm:ResourceString Name=ViewPageDailyNoteVerify}"/>
<AppBarButton Icon="{shcm:FontIcon Glyph=&#xE713;}" Label="{shcm:ResourceString Name=ViewPageDailyNoteNotificationSetting}">
<AppBarButton Icon="{shcm:FontIcon Glyph={StaticResource FontIconContentSetting}}" Label="{shcm:ResourceString Name=ViewPageDailyNoteNotificationSetting}">
<AppBarButton.Flyout>
<Flyout Placement="BottomEdgeAlignedRight">
<StackPanel>
@@ -133,288 +154,280 @@
StretchContentForSingleRow="False">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Padding="8" Style="{StaticResource BorderCardStyle}">
<Grid Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid MinHeight="40" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
Margin="4,0,0,4"
VerticalAlignment="Center"
Style="{StaticResource BaseTextBlockStyle}"
Text="{Binding UserGameRole}"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap"/>
<StackPanel
x:Name="ButtonPanel"
Grid.Column="1"
<Grid Padding="8" Style="{StaticResource BorderGridStyle}">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid.Resources>
<Storyboard x:Name="ButtonPanelVisibleStoryboard">
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonPanel" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Name="ButtonPanelCollapsedStoryboard">
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonPanel" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<mxi:Interaction.Behaviors>
<mxic:EventTriggerBehavior EventName="PointerEntered">
<mxim:ControlStoryboardAction Storyboard="{StaticResource ButtonPanelVisibleStoryboard}"/>
</mxic:EventTriggerBehavior>
<mxic:EventTriggerBehavior EventName="PointerExited">
<mxim:ControlStoryboardAction Storyboard="{StaticResource ButtonPanelCollapsedStoryboard}"/>
</mxic:EventTriggerBehavior>
</mxi:Interaction.Behaviors>
<Grid MinHeight="40" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<TextBlock
Grid.Column="0"
Margin="4,0,0,4"
VerticalAlignment="Center"
Style="{StaticResource BaseTextBlockStyle}"
Text="{Binding UserGameRole}"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap"/>
<StackPanel
x:Name="ButtonPanel"
Grid.Column="1"
HorizontalAlignment="Right"
Orientation="Horizontal"
Visibility="Collapsed">
<Button
MinHeight="36.8"
Margin="8,0,0,0"
HorizontalAlignment="Right"
Orientation="Horizontal"
Visibility="Collapsed">
<Button
MinHeight="36.8"
Margin="6,0,0,0"
HorizontalAlignment="Right"
VerticalAlignment="Stretch"
Background="Transparent"
BorderBrush="{x:Null}"
BorderThickness="0"
Command="{Binding DataContext.RemoveDailyNoteCommand, Source={StaticResource ViewModelBindingProxy}}"
CommandParameter="{Binding}"
Content="&#xE74D;"
FontFamily="{StaticResource SymbolThemeFontFamily}"
ToolTipService.ToolTip="{shcm:ResourceString Name=ViewPageDailyNoteRemoveToolTip}"/>
<Button
MinHeight="36.8"
Margin="8,0,0,0"
VerticalAlignment="Stretch"
Background="Transparent"
BorderBrush="{x:Null}"
BorderThickness="0"
Command="{Binding DataContext.ModifyNotificationCommand, Source={StaticResource ViewModelBindingProxy}}"
CommandParameter="{Binding}"
Content="&#xE713;"
FontFamily="{StaticResource SymbolThemeFontFamily}"
ToolTipService.ToolTip="{shcm:ResourceString Name=ViewPageDailyNoteNotificationSetting}"/>
VerticalAlignment="Stretch"
Background="Transparent"
BorderBrush="{x:Null}"
BorderThickness="0"
Command="{Binding DataContext.RemoveDailyNoteCommand, Source={StaticResource ViewModelBindingProxy}}"
CommandParameter="{Binding}"
Content="{StaticResource FontIconContentDelete}"
FontFamily="{StaticResource SymbolThemeFontFamily}"
ToolTipService.ToolTip="{shcm:ResourceString Name=ViewPageDailyNoteRemoveToolTip}"/>
<Button
MinHeight="36.8"
Margin="8,0,0,0"
VerticalAlignment="Stretch"
Background="Transparent"
BorderBrush="{x:Null}"
BorderThickness="0"
Command="{Binding DataContext.ModifyNotificationCommand, Source={StaticResource ViewModelBindingProxy}}"
CommandParameter="{Binding}"
Content="{StaticResource FontIconContentSetting}"
FontFamily="{StaticResource SymbolThemeFontFamily}"
ToolTipService.ToolTip="{shcm:ResourceString Name=ViewPageDailyNoteNotificationSetting}"/>
</StackPanel>
</Grid>
<StackPanel
Grid.Row="1"
Margin="0,8,0,0"
Spacing="12">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
Width="40"
Height="40"
VerticalAlignment="Center">
<Image Width="32" Source="ms-appx:///Resource/Icon/UI_ItemIcon_210.png"/>
<ProgressRing
Width="40"
Height="40"
Background="{StaticResource CardBackgroundFillColorDefaultBrush}"
IsIndeterminate="False"
Maximum="{Binding DailyNote.MaxResin, Mode=OneWay}"
Value="{Binding DailyNote.CurrentResin, Mode=OneWay}"/>
</Grid>
<StackPanel Grid.Column="1" Margin="12,0,0,0">
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding DailyNote.ResinFormatted, Mode=OneWay}"/>
<TextBlock
Opacity="0.6"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding DailyNote.ResinRecoveryTargetTime, Mode=OneWay}"/>
</StackPanel>
</Grid>
<StackPanel
Grid.Row="1"
Margin="0,8,0,0"
Spacing="12">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
Width="40"
Height="40"
VerticalAlignment="Center">
<shci:CachedImage Width="32" Source="{StaticResource UI_ItemIcon_204}"/>
<ProgressRing
Width="40"
Height="40"
VerticalAlignment="Center">
<Image Width="32" Source="ms-appx:///Resource/Icon/UI_ItemIcon_210.png"/>
<ProgressRing
Width="40"
Height="40"
Background="{StaticResource CardBackgroundFillColorDefaultBrush}"
IsIndeterminate="False"
Maximum="{Binding DailyNote.MaxResin, Mode=OneWay}"
Value="{Binding DailyNote.CurrentResin, Mode=OneWay}"/>
</Grid>
<StackPanel Grid.Column="1" Margin="12,0,0,0">
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding DailyNote.ResinFormatted, Mode=OneWay}"/>
<TextBlock
Opacity="0.6"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding DailyNote.ResinRecoveryTargetTime, Mode=OneWay}"/>
</StackPanel>
Background="{StaticResource CardBackgroundFillColorDefaultBrush}"
IsIndeterminate="False"
Maximum="{Binding DailyNote.MaxHomeCoin, Mode=OneWay}"
Value="{Binding DailyNote.CurrentHomeCoin, Mode=OneWay}"/>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
<StackPanel Grid.Column="1" Margin="12,0,0,0">
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding DailyNote.HomeCoinFormatted, Mode=OneWay}"/>
<TextBlock
Opacity="0.6"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding DailyNote.HomeCoinRecoveryTargetTimeFormatted, Mode=OneWay}"/>
</StackPanel>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
Width="40"
Height="40"
VerticalAlignment="Center">
<Image Width="32" Source="ms-appx:///Resource/Icon/UI_MarkQuest_Events_Proce.png"/>
<ProgressRing
Width="40"
Height="40"
VerticalAlignment="Center">
<shci:CachedImage Width="32" Source="{StaticResource UI_ItemIcon_204}"/>
<ProgressRing
Width="40"
Height="40"
Background="{StaticResource CardBackgroundFillColorDefaultBrush}"
IsIndeterminate="False"
Maximum="{Binding DailyNote.MaxHomeCoin, Mode=OneWay}"
Value="{Binding DailyNote.CurrentHomeCoin, Mode=OneWay}"/>
</Grid>
<StackPanel Grid.Column="1" Margin="12,0,0,0">
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding DailyNote.HomeCoinFormatted, Mode=OneWay}"/>
<TextBlock
Opacity="0.6"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding DailyNote.HomeCoinRecoveryTargetTimeFormatted, Mode=OneWay}"/>
</StackPanel>
Background="{StaticResource CardBackgroundFillColorDefaultBrush}"
IsIndeterminate="False"
Maximum="{Binding DailyNote.TotalTaskNum, Mode=OneWay}"
Value="{Binding DailyNote.FinishedTaskNum, Mode=OneWay}"/>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
<StackPanel Grid.Column="1" Margin="12,0,0,0">
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding DailyNote.TaskFormatted, Mode=OneWay}"/>
<TextBlock
Opacity="0.6"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding DailyNote.ExtraTaskRewardDescription, Mode=OneWay}"/>
</StackPanel>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
Width="40"
Height="40"
VerticalAlignment="Center">
<Image Width="32" Source="ms-appx:///Resource/Icon/UI_MarkTower.png"/>
<ProgressRing
Width="40"
Height="40"
VerticalAlignment="Center">
<Image Width="32" Source="ms-appx:///Resource/Icon/UI_MarkQuest_Events_Proce.png"/>
<ProgressRing
Width="40"
Height="40"
Background="{StaticResource CardBackgroundFillColorDefaultBrush}"
IsIndeterminate="False"
Maximum="{Binding DailyNote.TotalTaskNum, Mode=OneWay}"
Value="{Binding DailyNote.FinishedTaskNum, Mode=OneWay}"/>
</Grid>
<StackPanel Grid.Column="1" Margin="12,0,0,0">
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding DailyNote.TaskFormatted, Mode=OneWay}"/>
<TextBlock
Opacity="0.6"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding DailyNote.ExtraTaskRewardDescription, Mode=OneWay}"/>
</StackPanel>
Background="{StaticResource CardBackgroundFillColorDefaultBrush}"
IsIndeterminate="False"
Maximum="{Binding DailyNote.ResinDiscountNumLimit, Mode=OneWay}"
Value="{Binding DailyNote.ResinDiscountUsedNum, Mode=OneWay}"/>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
<StackPanel Grid.Column="1" Margin="12,0,0,0">
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding DailyNote.ResinDiscountFormatted, Mode=OneWay}"/>
<TextBlock
Opacity="0.6"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{shcm:ResourceString Name=ViewPageDailyNoteResinDiscountUsed}"/>
</StackPanel>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
Width="40"
Height="40">
<Image Width="32" Source="ms-appx:///Resource/Icon/UI_ItemIcon_220021.png"/>
<ProgressRing
Width="40"
Height="40"
VerticalAlignment="Center">
<Image Width="32" Source="ms-appx:///Resource/Icon/UI_MarkTower.png"/>
<ProgressRing
Width="40"
Height="40"
Background="{StaticResource CardBackgroundFillColorDefaultBrush}"
IsIndeterminate="False"
Maximum="{Binding DailyNote.ResinDiscountNumLimit, Mode=OneWay}"
Value="{Binding DailyNote.ResinDiscountUsedNum, Mode=OneWay}"/>
</Grid>
<StackPanel Grid.Column="1" Margin="12,0,0,0">
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding DailyNote.ResinDiscountFormatted, Mode=OneWay}"/>
<TextBlock
Opacity="0.6"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{shcm:ResourceString Name=ViewPageDailyNoteResinDiscountUsed}"/>
</StackPanel>
Background="{StaticResource CardBackgroundFillColorDefaultBrush}"
IsIndeterminate="False"
Maximum="604800"
Value="{Binding DailyNote.Transformer.RecoveryTime.TotalSeconds, Mode=OneWay}"/>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
Width="40"
Height="40">
<Image Width="32" Source="ms-appx:///Resource/Icon/UI_ItemIcon_220021.png"/>
<ProgressRing
<StackPanel Grid.Column="1" Margin="12,0,0,0">
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding DailyNote.Transformer.RecoveryTime.ReachedFormatted, Mode=OneWay}"/>
<TextBlock
Opacity="0.6"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding DailyNote.Transformer.RecoveryTime.TimeFormatted, Mode=OneWay}"/>
</StackPanel>
</Grid>
</StackPanel>
<MenuFlyoutSeparator Grid.Row="2" Margin="8,16,8,0"/>
<ItemsControl
Grid.Row="3"
Margin="0,16,0,0"
ItemsSource="{Binding DailyNote.Expeditions, Mode=OneWay}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<cwuc:UniformGrid
ColumnSpacing="8"
Columns="2"
RowSpacing="8"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
Width="40"
Height="40"
Background="{StaticResource CardBackgroundFillColorDefaultBrush}"
IsIndeterminate="False"
Maximum="604800"
Value="{Binding DailyNote.Transformer.RecoveryTime.TotalSeconds, Mode=OneWay}"/>
</Grid>
<StackPanel Grid.Column="1" Margin="12,0,0,0">
<TextBlock Style="{StaticResource SubtitleTextBlockStyle}" Text="{Binding DailyNote.Transformer.RecoveryTime.ReachedFormatted, Mode=OneWay}"/>
<TextBlock
Opacity="0.6"
Style="{StaticResource CaptionTextBlockStyle}"
Text="{Binding DailyNote.Transformer.RecoveryTime.TimeFormatted, Mode=OneWay}"/>
</StackPanel>
</Grid>
</StackPanel>
<MenuFlyoutSeparator Grid.Row="2" Margin="8,16,8,0"/>
<ItemsControl
Grid.Row="3"
Margin="0,16,0,0"
ItemsSource="{Binding DailyNote.Expeditions, Mode=OneWay}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<cwuc:UniformGrid
ColumnSpacing="8"
Columns="2"
RowSpacing="8"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid
Grid.Column="0"
Width="40"
Height="40">
<shci:CachedImage
Width="32"
Margin="0,0,0,8"
Source="{Binding AvatarSideIcon, Mode=OneWay}"/>
<ProgressRing
Width="40"
Height="40"
Background="{StaticResource CardBackgroundFillColorDefaultBrush}"
IsIndeterminate="False"
Maximum="{Binding TotalTime, Mode=OneWay}"
Value="{Binding PassedTime, Mode=OneWay}"/>
</Grid>
<TextBlock
Grid.Column="1"
Margin="12,0,0,4"
VerticalAlignment="Center"
Style="{StaticResource BaseTextBlockStyle}"
Text="{Binding RemainedTimeFormatted, Mode=OneWay}"/>
</Grid>
Height="40">
<shci:CachedImage
Margin="0,0,0,8"
shvh:FrameworkElementHelper.SquareLength="32"
Source="{Binding AvatarSideIcon, Mode=OneWay}"/>
<ProgressRing
shvh:FrameworkElementHelper.SquareLength="40"
Background="{StaticResource CardBackgroundFillColorDefaultBrush}"
IsIndeterminate="False"
Maximum="{Binding TotalTime, Mode=OneWay}"
Value="{Binding PassedTime, Mode=OneWay}"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Grid.Resources>
<Storyboard x:Name="ButtonPanelVisibleStoryboard">
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonPanel" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Name="ButtonPanelCollapsedStoryboard">
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonPanel" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</Grid.Resources>
<mxi:Interaction.Behaviors>
<mxic:EventTriggerBehavior EventName="PointerEntered">
<mxim:ControlStoryboardAction Storyboard="{StaticResource ButtonPanelVisibleStoryboard}"/>
</mxic:EventTriggerBehavior>
<mxic:EventTriggerBehavior EventName="PointerExited">
<mxim:ControlStoryboardAction Storyboard="{StaticResource ButtonPanelCollapsedStoryboard}"/>
</mxic:EventTriggerBehavior>
</mxi:Interaction.Behaviors>
</Grid>
</Border>
<TextBlock
Grid.Column="1"
Margin="12,0,0,4"
VerticalAlignment="Center"
Style="{StaticResource BaseTextBlockStyle}"
Text="{Binding RemainedTimeFormatted, Mode=OneWay}"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</cwuc:AdaptiveGridView>

View File

@@ -5,27 +5,58 @@
xmlns:cwc="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mxi="using:Microsoft.Xaml.Interactivity"
xmlns:mxic="using:Microsoft.Xaml.Interactions.Core"
xmlns:shc="using:Snap.Hutao.Control"
xmlns:shcb="using:Snap.Hutao.Control.Behavior"
xmlns:shv="using:Snap.Hutao.ViewModel"
xmlns:shvc="using:Snap.Hutao.View.Control"
d:DataContext="{d:DesignInstance shv:TestViewModel}"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">
<ScrollViewer>
<StackPanel Margin="16" Spacing="{StaticResource SettingsCardSpacing}">
<cwc:SettingsCard
Command="{Binding DangerousLoginMihoyoBbsCommand}"
Header="DangerousLoginMihoyoBbsTest"
IsClickEnabled="True"/>
<cwc:SettingsCard Header="AdoptCalculatorDialogTest" IsClickEnabled="True">
<mxi:Interaction.Behaviors>
<mxic:EventTriggerBehavior EventName="Click">
<shcb:OpenAttachedFlyoutAction/>
</mxic:EventTriggerBehavior>
</mxi:Interaction.Behaviors>
<FlyoutBase.AttachedFlyout>
<Flyout LightDismissOverlayMode="On" Placement="Full">
<Flyout.FlyoutPresenterStyle>
<Style TargetType="FlyoutPresenter">
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderBrush" Value="{ThemeResource CardStrokeColorDefaultBrush}"/>
</Style>
</Flyout.FlyoutPresenterStyle>
<Grid>
<shvc:Webview2Viewer Source="http://webstatic.mihoyo.com/ys/event/e20200923adopt_calculator/index.html?bbs_presentation_style=fullscreen&amp;bbs_auth_required=true&amp;utm_source=bbs&amp;utm_medium=mys&amp;utm_campaign=GameRecord"/>
</Grid>
</Flyout>
</FlyoutBase.AttachedFlyout>
</cwc:SettingsCard>
<cwc:SettingsCard
Command="{Binding ShowCommunityGameRecordDialogCommand}"
Header="CommunityGameRecordDialogTest"
IsClickEnabled="True"/>
<cwc:SettingsCard
Command="{Binding ShowAdoptCalculatorDialogCommand}"
Header="AdoptCalculatorDialogTest"
IsClickEnabled="True"/>
<cwc:SettingsCard Header="CommunityGameRecordDialogTest" IsClickEnabled="True">
<mxi:Interaction.Behaviors>
<mxic:EventTriggerBehavior EventName="Click">
<shcb:OpenAttachedFlyoutAction/>
</mxic:EventTriggerBehavior>
</mxi:Interaction.Behaviors>
<FlyoutBase.AttachedFlyout>
<Flyout LightDismissOverlayMode="On" Placement="Full">
<Flyout.FlyoutPresenterStyle>
<Style TargetType="FlyoutPresenter">
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderBrush" Value="{ThemeResource CardStrokeColorDefaultBrush}"/>
</Style>
</Flyout.FlyoutPresenterStyle>
<Grid>
<shvc:Webview2Viewer Source="https://webstatic.mihoyo.com/app/community-game-records/index.html"/>
</Grid>
</Flyout>
</FlyoutBase.AttachedFlyout>
</cwc:SettingsCard>
<cwc:SettingsCard Header="RestartTest">
<StackPanel Orientation="Horizontal">

View File

@@ -1,14 +1,13 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Snap.Hutao.Core.Database;
using Snap.Hutao.Model.Entity;
using Snap.Hutao.Model.Entity.Database;
using Snap.Hutao.Service.DailyNote;
using Snap.Hutao.Service.Notification;
using Snap.Hutao.Service.User;
using Snap.Hutao.View.Dialog;
using Snap.Hutao.ViewModel.User;
using Snap.Hutao.Web.Request.QueryString;
using System.Collections.ObjectModel;
namespace Snap.Hutao.ViewModel.DailyNote;
@@ -36,6 +35,21 @@ internal sealed partial class DailyNoteViewModel : Abstraction.ViewModel
/// </summary>
public DailyNoteOptions Options { get => options; }
// TODO: 当切换用户后提醒此属性改变
public string VerifyUrl
{
get
{
if (UserAndUid.TryFromUser(userService.Current, out UserAndUid? userAndUid))
{
QueryString query = userAndUid.Uid.ToQueryString();
return $"https://webstatic.mihoyo.com/app/community-game-records/index.html?bbs_presentation_style=fullscreen#/ys/daily/?{query}";
}
return default!;
}
}
/// <summary>
/// 用户与角色集合
/// </summary>
@@ -67,11 +81,11 @@ internal sealed partial class DailyNoteViewModel : Abstraction.ViewModel
}
[Command("TrackRoleCommand")]
private async Task TrackRoleAsync(UserAndUid? role)
private async Task TrackRoleAsync(UserAndUid? userAndUid)
{
if (role is not null)
if (userAndUid is not null)
{
await dailyNoteService.AddDailyNoteAsync(role).ConfigureAwait(false);
await dailyNoteService.AddDailyNoteAsync(userAndUid).ConfigureAwait(false);
}
}
@@ -106,29 +120,4 @@ internal sealed partial class DailyNoteViewModel : Abstraction.ViewModel
}
}
}
[Command("DailyNoteVerificationCommand")]
private async Task VerifyDailyNoteVerificationAsync()
{
IInfoBarService infoBarService = serviceProvider.GetRequiredService<IInfoBarService>();
if (UserAndUid.TryFromUser(userService.Current, out UserAndUid? userAndUid))
{
if (userAndUid.User.IsOversea)
{
// TODO: Add verify support for oversea user
infoBarService.Warning(SH.ViewModelDailyNoteHoyolabVerificationUnsupported);
}
else
{
// ContentDialog must be created by main thread.
await taskContext.SwitchToMainThreadAsync();
await serviceProvider.CreateInstance<DailyNoteVerificationDialog>(userAndUid).ShowAsync();
}
}
else
{
infoBarService.Warning(SH.MustSelectUserAndUid);
}
}
}

View File

@@ -23,22 +23,6 @@ internal sealed partial class TestViewModel : Abstraction.ViewModel
return Task.CompletedTask;
}
[Command("ShowCommunityGameRecordDialogCommand")]
private async Task ShowCommunityGameRecordDialogAsync()
{
// ContentDialog must be created by main thread.
await taskContext.SwitchToMainThreadAsync();
await serviceProvider.CreateInstance<CommunityGameRecordDialog>().ShowAsync();
}
[Command("ShowAdoptCalculatorDialogCommand")]
private async Task ShowAdoptCalculatorDialogAsync()
{
// ContentDialog must be created by main thread.
await taskContext.SwitchToMainThreadAsync();
await serviceProvider.CreateInstance<AdoptCalculatorDialog>().ShowAsync();
}
[Command("RestartAppCommand")]
private void RestartApp(bool elevated)
{

View File

@@ -47,7 +47,7 @@ internal sealed class UserAndUid : IMappingFrom<UserAndUid, EntityUser, PlayerUi
/// <param name="user">用户</param>
/// <param name="userAndUid">用户与角色</param>
/// <returns>是否转换成功</returns>
public static bool TryFromUser(User? user, [NotNullWhen(true)] out UserAndUid? userAndUid)
public static bool TryFromUser([NotNullWhen(true)] User? user, [NotNullWhen(true)] out UserAndUid? userAndUid)
{
if (user is not null && user.SelectedUserGameRole is not null)
{

View File

@@ -36,23 +36,21 @@ internal class MiHoYoJSInterface
document.querySelector('body').appendChild(st);
""";
private readonly CoreWebView2 webView;
private readonly IServiceProvider serviceProvider;
private readonly CoreWebView2 webView;
private readonly UserAndUid userAndUid;
private readonly ITaskContext taskContext;
private readonly ILogger<MiHoYoJSInterface> logger;
private readonly SemaphoreSlim webMessageSemaphore = new(1);
/// <summary>
/// 构造一个新的调用桥
/// </summary>
/// <param name="serviceProvider">服务提供器</param>
/// <param name="webView">webview2</param>
public MiHoYoJSInterface(IServiceProvider serviceProvider, CoreWebView2 webView)
public MiHoYoJSInterface(IServiceProvider serviceProvider, CoreWebView2 webView, UserAndUid userAndUid)
{
this.webView = webView;
taskContext = serviceProvider.GetRequiredService<ITaskContext>();
this.serviceProvider = serviceProvider;
this.webView = webView;
this.userAndUid = userAndUid;
taskContext = serviceProvider.GetRequiredService<ITaskContext>();
logger = serviceProvider.GetRequiredService<ILogger<MiHoYoJSInterface>>();
webView.WebMessageReceived += OnWebMessageReceived;
@@ -69,10 +67,9 @@ internal class MiHoYoJSInterface
/// <returns>响应</returns>
public virtual async Task<IJsResult?> GetActionTicketAsync(JsParam<ActionTypePayload> jsParam)
{
User user = serviceProvider.GetRequiredService<IUserService>().Current!;
return await serviceProvider
.GetRequiredService<AuthClient>()
.GetActionTicketBySTokenAsync(jsParam.Payload.ActionType, user.Entity)
.GetActionTicketBySTokenAsync(jsParam.Payload.ActionType, userAndUid.User)
.ConfigureAwait(false);
}

View File

@@ -2,6 +2,7 @@
// Licensed under the MIT license.
using Microsoft.Web.WebView2.Core;
using Snap.Hutao.ViewModel.User;
using Snap.Hutao.Web.Bridge.Model;
using Snap.Hutao.Web.Hoyolab;
@@ -21,8 +22,8 @@ internal sealed class SignInJSInterfaceOversea : MiHoYoJSInterface
private readonly ILogger<MiHoYoJSInterface> logger;
/// <inheritdoc cref="MiHoYoJSInterface(IServiceProvider, CoreWebView2)"/>
public SignInJSInterfaceOversea(CoreWebView2 webView, IServiceProvider serviceProvider)
: base(serviceProvider, webView)
public SignInJSInterfaceOversea(CoreWebView2 webView, IServiceProvider serviceProvider, UserAndUid userAndUid)
: base(serviceProvider, webView, userAndUid)
{
logger = serviceProvider.GetRequiredService<ILogger<MiHoYoJSInterface>>();
webView.DOMContentLoaded += OnDOMContentLoaded;

View File

@@ -2,6 +2,7 @@
// Licensed under the MIT license.
using Microsoft.Web.WebView2.Core;
using Snap.Hutao.ViewModel.User;
using Snap.Hutao.Web.Bridge.Model;
using Snap.Hutao.Web.Hoyolab;
@@ -14,8 +15,8 @@ namespace Snap.Hutao.Web.Bridge;
internal sealed class SignInJsInterface : MiHoYoJSInterface
{
/// <inheritdoc cref="MiHoYoJSInterface(IServiceProvider, CoreWebView2)"/>
public SignInJsInterface(CoreWebView2 webView, IServiceProvider serviceProvider)
: base(serviceProvider, webView)
public SignInJsInterface(CoreWebView2 webView, IServiceProvider serviceProvider, UserAndUid userAndUid)
: base(serviceProvider, webView, userAndUid)
{
}

View File

@@ -39,7 +39,7 @@ internal sealed class AvatarPromotionDelta
/// 技能
/// </summary>
[JsonPropertyName("skill_list")]
public IEnumerable<PromotionDelta>? SkillList { get; set; }
public List<PromotionDelta>? SkillList { get; set; }
/// <summary>
/// 武器