This commit is contained in:
DismissedLight
2024-01-07 23:23:59 +08:00
parent 1ebcc2fc89
commit 04df5a7bf1
23 changed files with 494 additions and 81 deletions

View File

@@ -7,6 +7,7 @@ namespace Snap.Hutao.Control;
[TemplateVisualState(Name = "LoadingIn", GroupName = "CommonStates")]
[TemplateVisualState(Name = "LoadingOut", GroupName = "CommonStates")]
[TemplatePart(Name = "ContentGrid", Type = typeof(FrameworkElement))]
internal class Loading : Microsoft.UI.Xaml.Controls.ContentControl
{
public static readonly DependencyProperty IsLoadingProperty = DependencyProperty.Register(nameof(IsLoading), typeof(bool), typeof(Loading), new PropertyMetadata(default(bool), IsLoadingPropertyChanged));

View File

@@ -3,7 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:shc="using:Snap.Hutao.Control">
<Style TargetType="shc:Loading">
<Style BasedOn="{StaticResource DefaultLoadingStyle}" TargetType="shc:Loading"/>
<Style x:Key="DefaultLoadingStyle" TargetType="shc:Loading">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>

View File

@@ -18,12 +18,15 @@ internal sealed class FontIconExtension : MarkupExtension
/// </summary>
public string Glyph { get; set; } = default!;
public double FontSize { get; set; } = 12;
/// <inheritdoc/>
protected override object ProvideValue()
{
return new FontIcon()
{
Glyph = Glyph,
FontSize = FontSize,
};
}
}

View File

@@ -20,6 +20,9 @@
<ItemsPanelTemplate x:Key="StackPanelSpacing4Template">
<StackPanel Spacing="4"/>
</ItemsPanelTemplate>
<ItemsPanelTemplate x:Key="StackPanelSpacing8Template">
<StackPanel Spacing="8"/>
</ItemsPanelTemplate>
<ItemsPanelTemplate x:Key="UniformGridColumns2Spacing2Template">
<cwcont:UniformGrid
ColumnSpacing="2"

View File

@@ -11,6 +11,7 @@
<x:Double x:Key="SettingsCardContentControlSpacing">10</x:Double>
<Thickness x:Key="SettingsCardAlignSettingsExpanderPadding">16,16,44,16</Thickness>
<Thickness x:Key="SettingsExpanderItemHasIconPadding">16,8,16,8</Thickness>
<Style
x:Key="SettingsSectionHeaderTextBlockStyle"

View File

@@ -27,6 +27,7 @@
<!-- EmotionIcon -->
<x:String x:Key="UI_EmotionIcon25">https://api.snapgenshin.com/static/raw/EmotionIcon/UI_EmotionIcon25.png</x:String>
<x:String x:Key="UI_EmotionIcon52">https://api.snapgenshin.com/static/raw/EmotionIcon/UI_EmotionIcon52.png</x:String>
<x:String x:Key="UI_EmotionIcon71">https://api.snapgenshin.com/static/raw/EmotionIcon/UI_EmotionIcon71.png</x:String>
<x:String x:Key="UI_EmotionIcon250">https://api.snapgenshin.com/static/raw/EmotionIcon/UI_EmotionIcon250.png</x:String>
<x:String x:Key="UI_EmotionIcon271">https://api.snapgenshin.com/static/raw/EmotionIcon/UI_EmotionIcon271.png</x:String>

View File

@@ -1310,6 +1310,9 @@
<data name="ViewDialogUserTitle" xml:space="preserve">
<value>设置 Cookie</value>
</data>
<data name="ViewFeedbackHeader" xml:space="preserve">
<value>反馈中心</value>
</data>
<data name="ViewGachaLogHeader" xml:space="preserve">
<value>祈愿记录</value>
</data>
@@ -1850,6 +1853,12 @@
<data name="ViewPageDailyNoteVerify" xml:space="preserve">
<value>验证当前用户与角色</value>
</data>
<data name="ViewPageFeedbackAutoSuggestBoxPlaceholder" xml:space="preserve">
<value>搜索问题与建议</value>
</data>
<data name="ViewPageFeedBackBasicInformation" xml:space="preserve">
<value>基本信息</value>
</data>
<data name="ViewPageGachaLogAggressiveRefresh" xml:space="preserve">
<value>全量刷新</value>
</data>
@@ -2606,6 +2615,9 @@
<data name="ViewSettingFolderViewOpenFolderAction" xml:space="preserve">
<value>打开文件夹</value>
</data>
<data name="ViewSettingHeader" xml:space="preserve">
<value>设置</value>
</data>
<data name="ViewSpiralAbyssAvatarAppearanceRankDescription" xml:space="preserve">
<value>角色出场率 = 本层上阵该角色次数(层内重复出现只记一次)/ 深渊记录总数</value>
</data>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@@ -25,6 +25,11 @@ internal static class CultureOptionsExtension
return GetLocaleName(cultureInfo) == options.LocaleName;
}
public static string GetLanguageCodeForDocumentationSearch(this CultureOptions options)
{
return LocaleNames.GetLanguageCodeForDocumentationSearchFromLocaleName(options.LocaleName);
}
internal static string GetLocaleName(CultureInfo cultureInfo)
{
while (true)

View File

@@ -172,6 +172,8 @@ internal static class DiscordController
private static async ValueTask DiscordRunCallbacksAsync(CancellationToken cancellationToken)
{
int notRunningCounter = 0;
using (PeriodicTimer timer = new(TimeSpan.FromMilliseconds(500)))
{
try
@@ -190,7 +192,18 @@ internal static class DiscordController
DiscordResult result = DiscordCoreRunRunCallbacks();
if (result is not DiscordResult.Ok)
{
System.Diagnostics.Debug.WriteLine($"[Discord.GameSDK ERROR]:{result:D} {result}");
if (result is DiscordResult.NotRunning)
{
if (++notRunningCounter > 20)
{
Stop();
}
}
else
{
notRunningCounter = 0;
System.Diagnostics.Debug.WriteLine($"[Discord.GameSDK ERROR]:{result:D} {result}");
}
}
}
catch (SEHException ex)

View File

@@ -74,4 +74,15 @@ internal static class LocaleNames
return !string.IsNullOrEmpty(languageCode);
}
public static string GetLanguageCodeForDocumentationSearchFromLocaleName(string localeName)
{
return localeName switch
{
ID => "id-id",
RU => "ru-ru",
CHS => "zh-cn",
_ => "en-us",
};
}
}

View File

@@ -23,7 +23,7 @@ internal sealed partial class MetadataOptions
{
if (fallbackDataFolder is null)
{
fallbackDataFolder = Path.Combine(runtimeOptions.DataFolder, "Metadata", "CHS");
fallbackDataFolder = Path.Combine(runtimeOptions.DataFolder, "Metadata", LocaleNames.CHS);
Directory.CreateDirectory(fallbackDataFolder);
}

View File

@@ -13,21 +13,23 @@ internal sealed partial class DocumentationProvider : IDocumentationProvider
private static readonly Dictionary<Type, string> TypeDocumentations = new()
{
[typeof(AchievementPage)] = "https://hut.ao/features/achievements.html",
[typeof(AnnouncementPage)] = "https://hut.ao/features/dashboard.html",
[typeof(AvatarPropertyPage)] = "https://hut.ao/features/character-data.html",
[typeof(CultivationPage)] = "https://hut.ao/features/develop-plan.html",
[typeof(DailyNotePage)] = "https://hut.ao/features/real-time-notes.html",
[typeof(GachaLogPage)] = "https://hut.ao/features/wish-export.html",
[typeof(LaunchGamePage)] = "https://hut.ao/features/game-launcher.html",
[typeof(LoginHoyoverseUserPage)] = "https://hut.ao/features/mhy-account-switch.html",
[typeof(LoginMihoyoUserPage)] = "https://hut.ao/features/mhy-account-switch.html",
[typeof(SettingPage)] = "https://hut.ao/features/hutao-settings.html",
[typeof(GachaLogPage)] = "https://hut.ao/features/wish-export.html",
[typeof(AchievementPage)] = "https://hut.ao/features/achievements.html",
[typeof(DailyNotePage)] = "https://hut.ao/features/real-time-notes.html",
[typeof(AvatarPropertyPage)] = "https://hut.ao/features/character-data.html",
[typeof(SpiralAbyssRecordPage)] = "https://hut.ao/features/hutao-API.html",
[typeof(TestPage)] = Home,
[typeof(CultivationPage)] = "https://hut.ao/features/develop-plan.html",
[typeof(WikiAvatarPage)] = "https://hut.ao/features/character-wiki.html",
[typeof(WikiMonsterPage)] = "https://hut.ao/features/monster-wiki.html",
[typeof(WikiWeaponPage)] = "https://hut.ao/features/weapon-wiki.html",
[typeof(SettingPage)] = "https://hut.ao/features/hutao-settings.html",
[typeof(LoginHoyoverseUserPage)] = "https://hut.ao/features/mhy-account-switch.html",
[typeof(LoginMihoyoUserPage)] = "https://hut.ao/features/mhy-account-switch.html",
[typeof(TestPage)] = Home,
};
private readonly INavigationService navigationService;

View File

@@ -128,6 +128,7 @@
<None Remove="Resource\Navigation\DailyNote.png" />
<None Remove="Resource\Navigation\Database.png" />
<None Remove="Resource\Navigation\Documentation.png" />
<None Remove="Resource\Navigation\Feedback.png" />
<None Remove="Resource\Navigation\GachaLog.png" />
<None Remove="Resource\Navigation\LaunchGame.png" />
<None Remove="Resource\Navigation\SpiralAbyss.png" />
@@ -186,6 +187,7 @@
<None Remove="View\Page\AvatarPropertyPage.xaml" />
<None Remove="View\Page\CultivationPage.xaml" />
<None Remove="View\Page\DailyNotePage.xaml" />
<None Remove="View\Page\FeedbackPage.xaml" />
<None Remove="View\Page\GachaLogPage.xaml" />
<None Remove="View\Page\LaunchGamePage.xaml" />
<None Remove="View\Page\LoginMihoyoUserPage.xaml" />
@@ -269,6 +271,7 @@
<Content Include="Resource\Navigation\DailyNote.png" />
<Content Include="Resource\Navigation\Database.png" />
<Content Include="Resource\Navigation\Documentation.png" />
<Content Include="Resource\Navigation\Feedback.png" />
<Content Include="Resource\Navigation\GachaLog.png" />
<Content Include="Resource\Navigation\LaunchGame.png" />
<Content Include="Resource\Navigation\SpiralAbyss.png" />
@@ -345,6 +348,11 @@
<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
<ItemGroup>
<Page Update="View\Page\FeedbackPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Page Update="View\Dialog\ReconfirmDialog.xaml">
<Generator>MSBuild:Compile</Generator>

View File

@@ -27,6 +27,10 @@
shvh:NavHelper.NavigateTo="shvp:AnnouncementPage"
Content="{shcm:ResourceString Name=ViewAnnouncementHeader}"
Icon="{shcm:BitmapIcon Source=ms-appx:///Resource/Navigation/Announcement.png}"/>
<NavigationViewItem
shvh:NavHelper.NavigateTo="shvp:FeedbackPage"
Content="{shcm:ResourceString Name=ViewFeedbackHeader}"
Icon="{shcm:BitmapIcon Source=ms-appx:///Resource/Navigation/Feedback.png}"/>
<NavigationViewItemHeader Content="{shcm:ResourceString Name=ViewToolHeader}"/>

View File

@@ -0,0 +1,233 @@
<shc:ScopedPage
x:Class="Snap.Hutao.View.Page.FeedbackPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:clw="using:CommunityToolkit.Labs.WinUI"
xmlns:cwb="using:CommunityToolkit.WinUI.Behaviors"
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:shch="using:Snap.Hutao.Control.Helper"
xmlns:shci="using:Snap.Hutao.Control.Image"
xmlns:shcm="using:Snap.Hutao.Control.Markup"
xmlns:shvf="using:Snap.Hutao.ViewModel.Feedback"
d:DataContext="{d:DesignInstance shvf:FeedbackViewModel}"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">
<mxi:Interaction.Behaviors>
<shcb:InvokeCommandOnLoadedBehavior Command="{Binding OpenUICommand}"/>
</mxi:Interaction.Behaviors>
<Grid>
<SplitView
DisplayMode="Inline"
IsPaneOpen="True"
OpenPaneLength="400"
PaneBackground="{x:Null}"
PanePlacement="Right">
<SplitView.Pane>
<ScrollViewer>
<StackPanel Margin="16" Spacing="3">
<cwc:SettingsExpander
Description="{Binding RuntimeOptions.Version}"
Header="{shcm:ResourceString Name=AppName}"
HeaderIcon="{shcm:FontIcon Glyph=&#xECAA;}"
IsExpanded="True">
<cwc:SettingsExpander.Items>
<cwc:SettingsCard
ActionIcon="{shcm:FontIcon Glyph=&#xE8C8;}"
ActionIconToolTip="{shcm:ResourceString Name=ViewPageSettingCopyDeviceIdAction}"
Command="{Binding CopyDeviceIdCommand}"
Description="{Binding RuntimeOptions.DeviceId}"
Header="{shcm:ResourceString Name=ViewPageSettingDeviceIdHeader}"
IsClickEnabled="True"/>
<cwc:SettingsCard Description="{Binding IPInformation}" Header="{shcm:ResourceString Name=ViewPageSettingDeviceIpHeader}"/>
<cwc:SettingsCard Description="{Binding RuntimeOptions.WebView2Version}" Header="{shcm:ResourceString Name=ViewPageSettingWebview2Header}"/>
</cwc:SettingsExpander.Items>
</cwc:SettingsExpander>
<cwc:SettingsExpander
Header="功能指南"
HeaderIcon="{shcm:FontIcon Glyph=&#xF8A5;}"
IsExpanded="True">
<cwc:SettingsExpander.Items>
<cwc:SettingsCard
Padding="{ThemeResource SettingsExpanderItemHasIconPadding}"
Command="{Binding NavigateToUriCommand}"
CommandParameter="https://hut.ao/features/dashboard.html"
Header="{shcm:ResourceString Name=ViewAnnouncementHeader}"
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Navigation/Announcement.png}"
IsClickEnabled="True"/>
<cwc:SettingsCard
Padding="{ThemeResource SettingsExpanderItemHasIconPadding}"
Command="{Binding NavigateToUriCommand}"
CommandParameter="https://hut.ao/features/game-launcher.html"
Header="{shcm:ResourceString Name=ViewLaunchGameHeader}"
IsClickEnabled="True">
<cwc:SettingsCard.HeaderIcon>
<!-- This icon is not a square -->
<BitmapIcon
Width="24"
Height="24"
ShowAsMonochrome="False"
UriSource="ms-appx:///Resource/Navigation/LaunchGame.png"/>
</cwc:SettingsCard.HeaderIcon>
</cwc:SettingsCard>
<cwc:SettingsCard
Padding="{ThemeResource SettingsExpanderItemHasIconPadding}"
Command="{Binding NavigateToUriCommand}"
CommandParameter="https://hut.ao/features/wish-export.html"
Header="{shcm:ResourceString Name=ViewGachaLogHeader}"
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Navigation/GachaLog.png}"
IsClickEnabled="True"/>
<cwc:SettingsCard
Padding="{ThemeResource SettingsExpanderItemHasIconPadding}"
Command="{Binding NavigateToUriCommand}"
CommandParameter="https://hut.ao/features/achievements.html"
Header="{shcm:ResourceString Name=ViewAchievementHeader}"
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Navigation/Achievement.png}"
IsClickEnabled="True"/>
<cwc:SettingsCard
Padding="{ThemeResource SettingsExpanderItemHasIconPadding}"
Command="{Binding NavigateToUriCommand}"
CommandParameter="https://hut.ao/features/real-time-notes.html"
Header="{shcm:ResourceString Name=ViewDailyNoteHeader}"
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Navigation/DailyNote.png}"
IsClickEnabled="True"/>
<cwc:SettingsCard
Padding="{ThemeResource SettingsExpanderItemHasIconPadding}"
Command="{Binding NavigateToUriCommand}"
CommandParameter="https://hut.ao/features/character-data.html"
Header="{shcm:ResourceString Name=ViewAvatarPropertyHeader}"
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Navigation/AvatarProperty.png}"
IsClickEnabled="True"/>
<cwc:SettingsCard
Padding="{ThemeResource SettingsExpanderItemHasIconPadding}"
Command="{Binding NavigateToUriCommand}"
CommandParameter="https://hut.ao/features/hutao-API.html"
Header="{shcm:ResourceString Name=ViewSpiralAbyssHeader}"
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Navigation/SpiralAbyss.png}"
IsClickEnabled="True"/>
<cwc:SettingsCard
Padding="{ThemeResource SettingsExpanderItemHasIconPadding}"
Command="{Binding NavigateToUriCommand}"
CommandParameter="https://hut.ao/features/develop-plan.html"
Header="{shcm:ResourceString Name=ViewCultivationHeader}"
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Navigation/Cultivation.png}"
IsClickEnabled="True"/>
<cwc:SettingsCard
Padding="{ThemeResource SettingsExpanderItemHasIconPadding}"
Command="{Binding NavigateToUriCommand}"
CommandParameter="https://hut.ao/features/character-wiki.html"
Header="{shcm:ResourceString Name=ViewWikiAvatarHeader}"
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Navigation/WikiAvatar.png}"
IsClickEnabled="True"/>
<cwc:SettingsCard
Padding="{ThemeResource SettingsExpanderItemHasIconPadding}"
Command="{Binding NavigateToUriCommand}"
CommandParameter="https://hut.ao/features/weapon-wiki.html"
Header="{shcm:ResourceString Name=ViewWikiWeaponHeader}"
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Navigation/WikiWeapon.png}"
IsClickEnabled="True"/>
<cwc:SettingsCard
Padding="{ThemeResource SettingsExpanderItemHasIconPadding}"
Command="{Binding NavigateToUriCommand}"
CommandParameter="https://hut.ao/features/monster-wiki.html"
Header="{shcm:ResourceString Name=ViewWikiMonsterHeader}"
HeaderIcon="{shcm:BitmapIcon Source=ms-appx:///Resource/Navigation/WikiMonster.png}"
IsClickEnabled="True"/>
<cwc:SettingsCard
Padding="{ThemeResource SettingsExpanderItemHasIconPadding}"
Command="{Binding NavigateToUriCommand}"
CommandParameter="https://hut.ao/features/hutao-settings.html"
Header="{shcm:ResourceString Name=ViewSettingHeader}"
HeaderIcon="{shcm:FontIcon Glyph=&#xE713;}"
IsClickEnabled="True"/>
</cwc:SettingsExpander.Items>
</cwc:SettingsExpander>
</StackPanel>
</ScrollViewer>
</SplitView.Pane>
<Grid>
<Grid
Padding="16,16,0,16"
RowSpacing="8"
Visibility="{Binding IsInitialized, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<AutoSuggestBox
Grid.Row="0"
Height="36"
Margin="0,0,0,8"
HorizontalAlignment="Stretch"
VerticalContentAlignment="Center"
PlaceholderText="{shcm:ResourceString Name=ViewPageFeedbackAutoSuggestBoxPlaceholder}"
QueryIcon="{shcm:FontIcon Glyph=&#xE721;}"
Style="{StaticResource DefaultAutoSuggestBoxStyle}"
Text="{Binding SearchText, Mode=TwoWay}">
<mxi:Interaction.Behaviors>
<mxic:EventTriggerBehavior EventName="QuerySubmitted">
<mxic:InvokeCommandAction Command="{Binding SearchDocumentCommand}" CommandParameter="{Binding SearchText}"/>
</mxic:EventTriggerBehavior>
</mxi:Interaction.Behaviors>
</AutoSuggestBox>
<StackPanel
Grid.Row="1"
VerticalAlignment="Center"
Visibility="{Binding SearchResults.Count, Converter={StaticResource Int32ToVisibilityRevertConverter}}">
<shci:CachedImage
Height="120"
MinWidth="{ThemeResource SettingsCardContentControlMinWidth}"
EnableLazyLoading="False"
Source="{StaticResource UI_EmotionIcon52}"/>
<TextBlock
Margin="0,5,0,21"
HorizontalAlignment="Center"
Style="{StaticResource SubtitleTextBlockStyle}"
Text="暂无搜索结果"/>
</StackPanel>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Hidden">
<ItemsControl
ItemContainerTransitions="{ThemeResource ListViewLikeThemeTransitions}"
ItemsPanel="{ThemeResource StackPanelSpacing8Template}"
ItemsSource="{Binding SearchResults}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Style="{ThemeResource BorderCardStyle}">
<HyperlinkButton
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
NavigateUri="{Binding Url}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<BreadcrumbBar
Grid.Column="0"
Margin="4,8,8,4"
IsHitTestVisible="False"
ItemsSource="{Binding Hierarchy.DisplayLevels}"/>
</Grid>
</HyperlinkButton>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
<clw:Shimmer
CornerRadius="0"
IsActive="{Binding IsInitialized, Converter={StaticResource BoolNegationConverter}, Mode=OneWay}"
Visibility="{Binding IsInitialized, Converter={StaticResource BoolToVisibilityRevertConverter}, Mode=OneWay}"/>
</Grid>
</SplitView>
</Grid>
</shc:ScopedPage>

View File

@@ -0,0 +1,16 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Snap.Hutao.Control;
using Snap.Hutao.ViewModel.Feedback;
namespace Snap.Hutao.View.Page;
internal sealed partial class FeedbackPage : ScopedPage
{
public FeedbackPage()
{
InitializeWith<FeedbackViewModel>();
InitializeComponent();
}
}

View File

@@ -111,23 +111,6 @@
</shch:ScrollViewerHelper.RightPanel>
<Grid Padding="16" HorizontalAlignment="Left">
<StackPanel Grid.Column="0" Spacing="{StaticResource SettingsCardSpacing}">
<cwc:SettingsExpander
Description="{Binding RuntimeOptions.Version}"
Header="{shcm:ResourceString Name=AppName}"
HeaderIcon="{shcm:FontIcon Glyph=&#xECAA;}"
IsExpanded="True">
<cwc:SettingsExpander.Items>
<cwc:SettingsCard
ActionIcon="{shcm:FontIcon Glyph=&#xE8C8;}"
ActionIconToolTip="{shcm:ResourceString Name=ViewPageSettingCopyDeviceIdAction}"
Command="{Binding CopyDeviceIdCommand}"
Description="{Binding RuntimeOptions.DeviceId}"
Header="{shcm:ResourceString Name=ViewPageSettingDeviceIdHeader}"
IsClickEnabled="True"/>
<cwc:SettingsCard Description="{Binding IPInformation}" Header="{shcm:ResourceString Name=ViewPageSettingDeviceIpHeader}"/>
<cwc:SettingsCard Description="{Binding RuntimeOptions.WebView2Version}" Header="{shcm:ResourceString Name=ViewPageSettingWebview2Header}"/>
</cwc:SettingsExpander.Items>
</cwc:SettingsExpander>
<!--
https://github.com/DGP-Studio/Snap.Hutao/issues/1072
ItemsRepeater will behave abnormal if no direct scrollhost wrapping it

View File

@@ -0,0 +1,112 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Snap.Hutao.Core;
using Snap.Hutao.Core.IO.DataTransfer;
using Snap.Hutao.Service;
using Snap.Hutao.Service.Notification;
using Snap.Hutao.Web.Hutao;
using Snap.Hutao.Web.Hutao.Algolia;
using Snap.Hutao.Web.Response;
using System.Runtime.InteropServices;
using Windows.System;
namespace Snap.Hutao.ViewModel.Feedback;
[Injection(InjectAs.Scoped)]
[ConstructorGenerated]
internal sealed partial class FeedbackViewModel : Abstraction.ViewModel
{
private readonly HutaoInfrastructureClient hutaoInfrastructureClient;
private readonly HutaoDocumentationClient hutaoDocumentationClient;
private readonly IClipboardProvider clipboardProvider;
private readonly IInfoBarService infoBarService;
private readonly CultureOptions cultureOptions;
private readonly RuntimeOptions runtimeOptions;
private readonly ITaskContext taskContext;
private string? searchText;
private List<AlgoliaHit>? searchResults;
private IPInformation? ipInformation;
public RuntimeOptions RuntimeOptions { get => runtimeOptions; }
public string? SearchText { get => searchText; set => SetProperty(ref searchText, value); }
public List<AlgoliaHit>? SearchResults { get => searchResults; set => SetProperty(ref searchResults, value); }
public IPInformation? IPInformation { get => ipInformation; private set => SetProperty(ref ipInformation, value); }
protected override async ValueTask<bool> InitializeUIAsync()
{
Response<IPInformation> resp = await hutaoInfrastructureClient.GetIPInformationAsync().ConfigureAwait(false);
IPInformation info;
if (resp.IsOk())
{
info = resp.Data;
}
else
{
info = IPInformation.Default;
}
await taskContext.SwitchToMainThreadAsync();
IPInformation = info;
return true;
}
[Command("NavigateToUriCommand")]
private static async Task NavigateToUri(string? uri)
{
if (string.IsNullOrEmpty(uri))
{
return;
}
await Launcher.LaunchUriAsync(uri.ToUri());
}
[Command("SearchDocumentCommand")]
private async Task SearchDocumentAsync(string? searchText)
{
IsInitialized = false;
SearchResults = null;
if (string.IsNullOrEmpty(searchText))
{
IsInitialized = true;
return;
}
string language = cultureOptions.GetLanguageCodeForDocumentationSearch();
AlgoliaResponse? response = await hutaoDocumentationClient.QueryAsync(searchText, language).ConfigureAwait(false);
await taskContext.SwitchToMainThreadAsync();
if (response is { Results: [AlgoliaResult { Hits: { Count: > 0 } hits }, ..] })
{
SearchResults = [.. hits.DistinctBy(hit => hit.Url)];
}
else
{
SearchResults = null;
}
IsInitialized = true;
}
[Command("CopyDeviceIdCommand")]
private void CopyDeviceId()
{
try
{
clipboardProvider.SetText(RuntimeOptions.DeviceId);
infoBarService.Success(SH.ViewModelSettingCopyDeviceIdSuccess);
}
catch (COMException ex)
{
infoBarService.Error(ex);
}
}
}

View File

@@ -43,11 +43,9 @@ internal sealed partial class SettingViewModel : Abstraction.ViewModel
private readonly HomeCardOptions homeCardOptions = new();
private readonly IFileSystemPickerInteraction fileSystemPickerInteraction;
private readonly HutaoInfrastructureClient hutaoInfrastructureClient;
private readonly HutaoPassportViewModel hutaoPassportViewModel;
private readonly IContentDialogFactory contentDialogFactory;
private readonly INavigationService navigationService;
private readonly IClipboardProvider clipboardInterop;
private readonly IShellLinkInterop shellLinkInterop;
private readonly HutaoUserOptions hutaoUserOptions;
private readonly IInfoBarService infoBarService;
@@ -62,7 +60,6 @@ internal sealed partial class SettingViewModel : Abstraction.ViewModel
private NameValue<BackdropType>? selectedBackdropType;
private NameValue<CultureInfo>? selectedCulture;
private NameValue<Region>? selectedRegion;
private IPInformation? ipInformation;
private FolderViewModel? cacheFolderView;
private FolderViewModel? dataFolderView;
@@ -123,8 +120,6 @@ internal sealed partial class SettingViewModel : Abstraction.ViewModel
public FolderViewModel? DataFolderView { get => dataFolderView; set => SetProperty(ref dataFolderView, value); }
public IPInformation? IPInformation { get => ipInformation; private set => SetProperty(ref ipInformation, value); }
public bool IsAllocConsoleDebugModeEnabled
{
get => LocalSetting.Get(SettingKeys.IsAllocConsoleDebugModeEnabled, false);
@@ -177,27 +172,12 @@ internal sealed partial class SettingViewModel : Abstraction.ViewModel
}
}
protected override async ValueTask<bool> InitializeUIAsync()
protected override ValueTask<bool> InitializeUIAsync()
{
CacheFolderView = new(taskContext, runtimeOptions.LocalCache);
DataFolderView = new(taskContext, runtimeOptions.DataFolder);
Response<IPInformation> resp = await hutaoInfrastructureClient.GetIPInformationAsync().ConfigureAwait(false);
IPInformation info;
if (resp.IsOk())
{
info = resp.Data;
}
else
{
info = IPInformation.Default;
}
await taskContext.SwitchToMainThreadAsync();
IPInformation = info;
return true;
return ValueTask.FromResult(true);
}
[Command("ResetStaticResourceCommand")]
@@ -296,20 +276,6 @@ internal sealed partial class SettingViewModel : Abstraction.ViewModel
}
}
[Command("CopyDeviceIdCommand")]
private void CopyDeviceId()
{
try
{
clipboardInterop.SetText(RuntimeOptions.DeviceId);
infoBarService.Success(SH.ViewModelSettingCopyDeviceIdSuccess);
}
catch (COMException ex)
{
infoBarService.Error(ex);
}
}
[Command("DeleteUsersCommand")]
private async Task DangerousDeleteUsersAsync()
{

View File

@@ -1,19 +1,10 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient;
using Snap.Hutao.Web.Hutao.Response;
using Snap.Hutao.Web.Request.Builder;
using Snap.Hutao.Web.Request.Builder.Abstraction;
using System.Net.Http;
namespace Snap.Hutao.Web.Hutao.Algolia;
internal sealed class AlgoliaHierarchy
{
[JsonPropertyName("lvl0")]
public string? Lvl0 { get; set; }
[JsonPropertyName("lvl1")]
public string? Lvl1 { get; set; }
@@ -31,4 +22,56 @@ internal sealed class AlgoliaHierarchy
[JsonPropertyName("lvl6")]
public string? Lvl6 { get; set; }
public IEnumerable<string> DisplayLevels
{
get
{
return GetDisplayLevels();
IEnumerable<string> GetDisplayLevels()
{
if (string.IsNullOrEmpty(Lvl1))
{
yield break;
}
yield return Lvl1;
if (string.IsNullOrEmpty(Lvl2))
{
yield break;
}
yield return Lvl2;
if (string.IsNullOrEmpty(Lvl3))
{
yield break;
}
yield return Lvl3;
if (string.IsNullOrEmpty(Lvl4))
{
yield break;
}
yield return Lvl4;
if (string.IsNullOrEmpty(Lvl5))
{
yield break;
}
yield return Lvl5;
if (string.IsNullOrEmpty(Lvl6))
{
yield break;
}
yield return Lvl6;
}
}
}
}

View File

@@ -1,12 +1,6 @@
// Copyright (c) DGP Studio. All rights reserved.
// Licensed under the MIT license.
using Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient;
using Snap.Hutao.Web.Hutao.Response;
using Snap.Hutao.Web.Request.Builder;
using Snap.Hutao.Web.Request.Builder.Abstraction;
using System.Net.Http;
namespace Snap.Hutao.Web.Hutao.Algolia;
internal sealed class AlgoliaHit

View File

@@ -20,7 +20,7 @@ internal sealed partial class HutaoDocumentationClient
private readonly ILogger<HutaoDocumentationClient> logger;
private readonly HttpClient httpClient;
public async ValueTask<AlgoliaResponse?> QueryAsync(string query, string language, CancellationToken token)
public async ValueTask<AlgoliaResponse?> QueryAsync(string query, string language, CancellationToken token = default)
{
AlgoliaRequestsWrapper data = new()
{