diff --git a/src/Snap.Hutao/.editorconfig b/src/Snap.Hutao/.editorconfig index 55caa86a..7641a3f3 100644 --- a/src/Snap.Hutao/.editorconfig +++ b/src/Snap.Hutao/.editorconfig @@ -167,6 +167,9 @@ csharp_style_prefer_top_level_statements = true:silent csharp_style_prefer_readonly_struct = true:suggestion csharp_style_prefer_utf8_string_literals = true:suggestion +# SA1600: Elements should be documented +dotnet_diagnostic.SA1600.severity = none + [*.vb] #### 命名样式 #### diff --git a/src/Snap.Hutao/Snap.Hutao.SourceGeneration/Automation/CommandGenerator.cs b/src/Snap.Hutao/Snap.Hutao.SourceGeneration/Automation/CommandGenerator.cs index 78b34fe0..e0cafa7a 100644 --- a/src/Snap.Hutao/Snap.Hutao.SourceGeneration/Automation/CommandGenerator.cs +++ b/src/Snap.Hutao/Snap.Hutao.SourceGeneration/Automation/CommandGenerator.cs @@ -99,4 +99,4 @@ internal sealed class CommandGenerator : IIncrementalGenerator string normalizedClassName = classSymbol.ToDisplayString().Replace('<', '{').Replace('>', '}'); production.AddSource($"{normalizedClassName}.{commandName}.g.cs", code); } -} \ No newline at end of file +} diff --git a/src/Snap.Hutao/Snap.Hutao.SourceGeneration/Automation/DependencyPropertyGenerator.cs b/src/Snap.Hutao/Snap.Hutao.SourceGeneration/Automation/DependencyPropertyGenerator.cs new file mode 100644 index 00000000..b5adf057 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao.SourceGeneration/Automation/DependencyPropertyGenerator.cs @@ -0,0 +1,103 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Snap.Hutao.SourceGeneration.Primitive; +using System.Collections.Immutable; +using System.Linq; +using System.Threading; + +namespace Snap.Hutao.SourceGeneration.Automation; + +[Generator(LanguageNames.CSharp)] +internal sealed class DependencyPropertyGenerator : IIncrementalGenerator +{ + private const string AttributeName = "Snap.Hutao.Core.Annotation.DependencyPropertyAttribute"; + + public void Initialize(IncrementalGeneratorInitializationContext context) + { + IncrementalValueProvider> commands = + context.SyntaxProvider.CreateSyntaxProvider(FilterAttributedClasses, CommandMethod) + .Where(GeneratorSyntaxContext2.NotNull) + .Collect(); + + context.RegisterImplementationSourceOutput(commands, GenerateDependencyPropertyImplementations); + } + + private static bool FilterAttributedClasses(SyntaxNode node, CancellationToken token) + { + return node is ClassDeclarationSyntax classDeclarationSyntax + && classDeclarationSyntax.Modifiers.Count > 1 + && classDeclarationSyntax.HasAttributeLists(); + } + + private static GeneratorSyntaxContext2 CommandMethod(GeneratorSyntaxContext context, CancellationToken token) + { + if (context.TryGetDeclaredSymbol(token, out INamedTypeSymbol? methodSymbol)) + { + ImmutableArray attributes = methodSymbol.GetAttributes(); + if (attributes.Any(data => data.AttributeClass!.ToDisplayString() == AttributeName)) + { + return new(context, methodSymbol, attributes); + } + } + + return default; + } + + private static void GenerateDependencyPropertyImplementations(SourceProductionContext production, ImmutableArray context2s) + { + foreach (GeneratorSyntaxContext2 context2 in context2s.DistinctBy(c => c.Symbol.ToDisplayString())) + { + GenerateDependencyPropertyImplementation(production, context2); + } + } + + private static void GenerateDependencyPropertyImplementation(SourceProductionContext production, GeneratorSyntaxContext2 context2) + { + foreach (AttributeData propertyInfo in context2.Attributes.Where(attr => attr.AttributeClass!.ToDisplayString() == AttributeName)) + { + ImmutableArray arguments = propertyInfo.ConstructorArguments; + + string propertyName = (string)arguments[0].Value!; + string propertyType = arguments[0].Type!.ToDisplayString(); + string type = arguments[1].Value!.ToString(); + string defaultValue = arguments.Length > 2 + ? GetLiteralString(arguments[2]) + : "default"; + string className = context2.Symbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat); + + string code = $$""" + using Microsoft.UI.Xaml; + + namespace {{context2.Symbol.ContainingNamespace}}; + + partial class {{className}} + { + private DependencyProperty {{propertyName}}Property = + DependencyProperty.Register(nameof({{propertyName}}), typeof({{type}}), typeof({{className}}), new PropertyMetadata(({{type}}){{defaultValue}})); + + public {{type}} {{propertyName}} + { + get => ({{type}})GetValue({{propertyName}}Property); + set => SetValue({{propertyName}}Property, value); + } + } + """; + + string normalizedClassName = context2.Symbol.ToDisplayString().Replace('<', '{').Replace('>', '}'); + production.AddSource($"{normalizedClassName}.{propertyName}.g.cs", code); + } + } + + private static string GetLiteralString(TypedConstant typedConstant) + { + if (typedConstant.Value is bool boolValue) + { + return boolValue ? "true" : "false"; + } + + return typedConstant.Value!.ToString(); + } +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao.SourceGeneration/Snap.Hutao.SourceGeneration.csproj b/src/Snap.Hutao/Snap.Hutao.SourceGeneration/Snap.Hutao.SourceGeneration.csproj index 5064656f..70ebc863 100644 --- a/src/Snap.Hutao/Snap.Hutao.SourceGeneration/Snap.Hutao.SourceGeneration.csproj +++ b/src/Snap.Hutao/Snap.Hutao.SourceGeneration/Snap.Hutao.SourceGeneration.csproj @@ -10,14 +10,6 @@ Debug;Release;Debug As Fake Elevated - - True - - - - True - - diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Behavior/AutoHeightBehavior.cs b/src/Snap.Hutao/Snap.Hutao/Control/Behavior/AutoHeightBehavior.cs index 1b30b9e9..233b4ea6 100644 --- a/src/Snap.Hutao/Snap.Hutao/Control/Behavior/AutoHeightBehavior.cs +++ b/src/Snap.Hutao/Snap.Hutao/Control/Behavior/AutoHeightBehavior.cs @@ -10,29 +10,10 @@ namespace Snap.Hutao.Control.Behavior; /// 按给定比例自动调整高度的行为 /// [HighQuality] -internal sealed class AutoHeightBehavior : BehaviorBase +[DependencyProperty("TargetWidth", typeof(double), 1.0D)] +[DependencyProperty("TargetHeight", typeof(double), 1.0D)] +internal sealed partial class AutoHeightBehavior : BehaviorBase { - private static readonly DependencyProperty TargetWidthProperty = Property.DependBoxed(nameof(TargetWidth), BoxedValues.DoubleOne); - private static readonly DependencyProperty TargetHeightProperty = Property.DependBoxed(nameof(TargetHeight), BoxedValues.DoubleOne); - - /// - /// 目标宽度 - /// - public double TargetWidth - { - get => (double)GetValue(TargetWidthProperty); - set => SetValue(TargetWidthProperty, value); - } - - /// - /// 目标高度 - /// - public double TargetHeight - { - get => (double)GetValue(TargetHeightProperty); - set => SetValue(TargetHeightProperty, value); - } - /// protected override void OnAssociatedObjectLoaded() { diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Behavior/AutoWidthBehavior.cs b/src/Snap.Hutao/Snap.Hutao/Control/Behavior/AutoWidthBehavior.cs index 8215a032..3c8d0547 100644 --- a/src/Snap.Hutao/Snap.Hutao/Control/Behavior/AutoWidthBehavior.cs +++ b/src/Snap.Hutao/Snap.Hutao/Control/Behavior/AutoWidthBehavior.cs @@ -10,29 +10,10 @@ namespace Snap.Hutao.Control.Behavior; /// 按给定比例自动调整高度的行为 /// [HighQuality] -internal sealed class AutoWidthBehavior : BehaviorBase +[DependencyProperty("TargetWidth", typeof(double), 1.0D)] +[DependencyProperty("TargetHeight", typeof(double), 1.0D)] +internal sealed partial class AutoWidthBehavior : BehaviorBase { - private static readonly DependencyProperty TargetWidthProperty = Property.DependBoxed(nameof(TargetWidth), BoxedValues.DoubleOne); - private static readonly DependencyProperty TargetHeightProperty = Property.DependBoxed(nameof(TargetHeight), BoxedValues.DoubleOne); - - /// - /// 目标宽度 - /// - public double TargetWidth - { - get => (double)GetValue(TargetWidthProperty); - set => SetValue(TargetWidthProperty, value); - } - - /// - /// 目标高度 - /// - public double TargetHeight - { - get => (double)GetValue(TargetHeightProperty); - set => SetValue(TargetHeightProperty, value); - } - /// protected override void OnAssociatedObjectLoaded() { diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Behavior/InvokeCommandOnLoadedBehavior.cs b/src/Snap.Hutao/Snap.Hutao/Control/Behavior/InvokeCommandOnLoadedBehavior.cs index 33c61d85..a9e2e6c7 100644 --- a/src/Snap.Hutao/Snap.Hutao/Control/Behavior/InvokeCommandOnLoadedBehavior.cs +++ b/src/Snap.Hutao/Snap.Hutao/Control/Behavior/InvokeCommandOnLoadedBehavior.cs @@ -10,30 +10,10 @@ namespace Snap.Hutao.Control.Behavior; /// 在元素加载完成后执行命令的行为 /// [HighQuality] -internal sealed class InvokeCommandOnLoadedBehavior : BehaviorBase +[DependencyProperty("Command", typeof(ICommand))] +[DependencyProperty("CommandParameter", typeof(object))] +internal sealed partial class InvokeCommandOnLoadedBehavior : BehaviorBase { - private static readonly DependencyProperty CommandProperty = Property.Depend(nameof(Command)); - private static readonly DependencyProperty CommandParameterProperty = Property.Depend(nameof(CommandParameter)); - - /// - /// 待执行的命令 - /// - public ICommand Command - { - get => (ICommand)GetValue(CommandProperty); - set => SetValue(CommandProperty, value); - } - - /// - /// 命令参数 - /// - [MaybeNull] - public object CommandParameter - { - get => GetValue(CommandParameterProperty); - set => SetValue(CommandParameterProperty, value); - } - /// protected override void OnAssociatedObjectLoaded() { diff --git a/src/Snap.Hutao/Snap.Hutao/Control/BindingProxy.cs b/src/Snap.Hutao/Snap.Hutao/Control/BindingProxy.cs index 2065e1eb..9eae7d19 100644 --- a/src/Snap.Hutao/Snap.Hutao/Control/BindingProxy.cs +++ b/src/Snap.Hutao/Snap.Hutao/Control/BindingProxy.cs @@ -12,16 +12,7 @@ namespace Snap.Hutao.Control; /// when object is not used anymore. /// [HighQuality] -internal sealed class BindingProxy : DependencyObject +[DependencyProperty("DataContext", typeof(object))] +internal sealed partial class BindingProxy : DependencyObject { - private static readonly DependencyProperty DataContextProperty = Property.Depend(nameof(DataContext)); - - /// - /// 数据上下文 - /// - public object? DataContext - { - get => GetValue(DataContextProperty); - set => SetValue(DataContextProperty, value); - } } \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Extension/ContentDialogExtension.cs b/src/Snap.Hutao/Snap.Hutao/Control/Extension/ContentDialogExtension.cs index 4a89e01e..65977650 100644 --- a/src/Snap.Hutao/Snap.Hutao/Control/Extension/ContentDialogExtension.cs +++ b/src/Snap.Hutao/Snap.Hutao/Control/Extension/ContentDialogExtension.cs @@ -17,34 +17,13 @@ internal static class ContentDialogExtension /// 对话框 /// 任务上下文 /// 用于恢复用户交互 - public static async ValueTask BlockAsync(this ContentDialog contentDialog, ITaskContext taskContext) + public static async ValueTask BlockAsync(this ContentDialog contentDialog, ITaskContext taskContext) { await taskContext.SwitchToMainThreadAsync(); contentDialog.ShowAsync().AsTask().SafeForget(); // E_ASYNC_OPERATION_NOT_STARTED 0x80000019 // Only a single ContentDialog can be open at any time. - return new ContentDialogHider(contentDialog, taskContext); - } -} - -[SuppressMessage("", "SA1201")] -[SuppressMessage("", "SA1400")] -[SuppressMessage("", "SA1600")] -file readonly struct ContentDialogHider : IDisposable -{ - private readonly ContentDialog contentDialog; - private readonly ITaskContext taskContext; - - public ContentDialogHider(ContentDialog contentDialog, ITaskContext taskContext) - { - this.contentDialog = contentDialog; - this.taskContext = taskContext; - } - - public void Dispose() - { - // Hide() must be called on main thread. - taskContext.InvokeOnMainThread(contentDialog.Hide); + return new ContentDialogHideToken(contentDialog, taskContext); } } \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Extension/ContentDialogHideToken.cs b/src/Snap.Hutao/Snap.Hutao/Control/Extension/ContentDialogHideToken.cs new file mode 100644 index 00000000..c955bbe1 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Control/Extension/ContentDialogHideToken.cs @@ -0,0 +1,24 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +using Microsoft.UI.Xaml.Controls; + +namespace Snap.Hutao.Control.Extension; + +internal readonly struct ContentDialogHideToken : IDisposable +{ + private readonly ContentDialog contentDialog; + private readonly ITaskContext taskContext; + + public ContentDialogHideToken(ContentDialog contentDialog, ITaskContext taskContext) + { + this.contentDialog = contentDialog; + this.taskContext = taskContext; + } + + public void Dispose() + { + // Hide() must be called on main thread. + taskContext.InvokeOnMainThread(contentDialog.Hide); + } +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Image/CompositionImage.cs b/src/Snap.Hutao/Snap.Hutao/Control/Image/CompositionImage.cs index 8f663261..1d5acce0 100644 --- a/src/Snap.Hutao/Snap.Hutao/Control/Image/CompositionImage.cs +++ b/src/Snap.Hutao/Snap.Hutao/Control/Image/CompositionImage.cs @@ -20,10 +20,10 @@ namespace Snap.Hutao.Control.Image; /// 为其他图像类控件提供基类 /// [HighQuality] -internal abstract class CompositionImage : Microsoft.UI.Xaml.Controls.Control +[DependencyProperty("EnableLazyLoading", typeof(bool), true)] +internal abstract partial class CompositionImage : Microsoft.UI.Xaml.Controls.Control { private static readonly DependencyProperty SourceProperty = Property.Depend(nameof(Source), default(Uri), OnSourceChanged); - private static readonly DependencyProperty EnableLazyLoadingProperty = Property.DependBoxed(nameof(EnableLazyLoading), BoxedValues.True); private static readonly ConcurrentCancellationTokenSource LoadingTokenSource = new(); private readonly IServiceProvider serviceProvider; @@ -57,15 +57,6 @@ internal abstract class CompositionImage : Microsoft.UI.Xaml.Controls.Control set => SetValue(SourceProperty, value); } - /// - /// 启用延迟加载 - /// - public bool EnableLazyLoading - { - get => (bool)GetValue(EnableLazyLoadingProperty); - set => SetValue(EnableLazyLoadingProperty, value); - } - /// /// 合成组合视觉 /// diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Image/Gradient.cs b/src/Snap.Hutao/Snap.Hutao/Control/Image/Gradient.cs index de876a1f..ddd5b49b 100644 --- a/src/Snap.Hutao/Snap.Hutao/Control/Image/Gradient.cs +++ b/src/Snap.Hutao/Snap.Hutao/Control/Image/Gradient.cs @@ -13,31 +13,12 @@ namespace Snap.Hutao.Control.Image; /// 渐变图像 /// [HighQuality] -internal sealed class Gradient : CompositionImage +[DependencyProperty("BackgroundDirection", typeof(GradientDirection), GradientDirection.TopToBottom)] +[DependencyProperty("ForegroundDirection", typeof(GradientDirection), GradientDirection.TopToBottom)] +internal sealed partial class Gradient : CompositionImage { - private static readonly DependencyProperty BackgroundDirectionProperty = Property.Depend(nameof(BackgroundDirection), GradientDirection.TopToBottom); - private static readonly DependencyProperty ForegroundDirectionProperty = Property.Depend(nameof(ForegroundDirection), GradientDirection.TopToBottom); - private double imageAspectRatio; - /// - /// 背景方向 - /// - public GradientDirection BackgroundDirection - { - get => (GradientDirection)GetValue(BackgroundDirectionProperty); - set => SetValue(BackgroundDirectionProperty, value); - } - - /// - /// 前景方向 - /// - public GradientDirection ForegroundDirection - { - get => (GradientDirection)GetValue(ForegroundDirectionProperty); - set => SetValue(ForegroundDirectionProperty, value); - } - /// protected override void OnUpdateVisual(SpriteVisual spriteVisual) { diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Panel/AspectRatio.cs b/src/Snap.Hutao/Snap.Hutao/Control/Panel/AspectRatio.cs index 5666d646..6afb8fb3 100644 --- a/src/Snap.Hutao/Snap.Hutao/Control/Panel/AspectRatio.cs +++ b/src/Snap.Hutao/Snap.Hutao/Control/Panel/AspectRatio.cs @@ -10,31 +10,12 @@ namespace Snap.Hutao.Control.Panel; /// 纵横比控件 /// [HighQuality] -internal class AspectRatio : Microsoft.UI.Xaml.Controls.Control +[DependencyProperty("TargetWidth", typeof(double), 1.0D)] +[DependencyProperty("TargetHeight", typeof(double), 1.0D)] +internal sealed partial class AspectRatio : Microsoft.UI.Xaml.Controls.Control { private const double Epsilon = 2.2204460492503131e-016; - private static readonly DependencyProperty TargetWidthProperty = Property.DependBoxed(nameof(TargetWidth), BoxedValues.DoubleOne); - private static readonly DependencyProperty TargetHeightProperty = Property.DependBoxed(nameof(TargetHeight), BoxedValues.DoubleOne); - - /// - /// 目标宽度 - /// - public double TargetWidth - { - get => (double)GetValue(TargetWidthProperty); - set => SetValue(TargetWidthProperty, value); - } - - /// - /// 目标高度 - /// - public double TargetHeight - { - get => (double)GetValue(TargetHeightProperty); - set => SetValue(TargetHeightProperty, value); - } - /// protected override Size MeasureOverride(Size availableSize) { diff --git a/src/Snap.Hutao/Snap.Hutao/Core/Annotation/DependencyPropertyAttribute.cs b/src/Snap.Hutao/Snap.Hutao/Core/Annotation/DependencyPropertyAttribute.cs new file mode 100644 index 00000000..702c01e6 --- /dev/null +++ b/src/Snap.Hutao/Snap.Hutao/Core/Annotation/DependencyPropertyAttribute.cs @@ -0,0 +1,16 @@ +// Copyright (c) DGP Studio. All rights reserved. +// Licensed under the MIT license. + +namespace Snap.Hutao.Core.Annotation; + +[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)] +internal sealed class DependencyPropertyAttribute : Attribute +{ + public DependencyPropertyAttribute(string name, Type type) + { + } + + public DependencyPropertyAttribute(string name, Type type, object defaultValue) + { + } +} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Core/DependencyInjection/DependencyInjection.cs b/src/Snap.Hutao/Snap.Hutao/Core/DependencyInjection/DependencyInjection.cs index 85199c9c..70a6d363 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/DependencyInjection/DependencyInjection.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/DependencyInjection/DependencyInjection.cs @@ -5,6 +5,7 @@ using CommunityToolkit.Mvvm.Messaging; using Snap.Hutao.Core.Logging; using Snap.Hutao.Service; using System.Globalization; +using System.Runtime.CompilerServices; using Windows.Globalization; namespace Snap.Hutao.Core.DependencyInjection; @@ -46,6 +47,7 @@ internal static class DependencyInjection return serviceProvider; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] private static IServiceProvider InitializeCulture(this IServiceProvider serviceProvider) { AppOptions appOptions = serviceProvider.GetRequiredService(); diff --git a/src/Snap.Hutao/Snap.Hutao/Core/DependencyInjection/EnumerableServiceExtension.cs b/src/Snap.Hutao/Snap.Hutao/Core/DependencyInjection/EnumerableServiceExtension.cs index 7f8fab4c..77c4614b 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/DependencyInjection/EnumerableServiceExtension.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/DependencyInjection/EnumerableServiceExtension.cs @@ -18,6 +18,7 @@ internal static class EnumerableServiceExtension /// 服务集合 /// 名称 /// 对应的服务 + [Obsolete("该方法会导致不必要的服务实例化")] public static TService Pick(this IEnumerable services, string name) where TService : INamedService { @@ -31,6 +32,7 @@ internal static class EnumerableServiceExtension /// 服务集合 /// 是否为海外服/Hoyolab /// 对应的服务 + [Obsolete("该方法会导致不必要的服务实例化")] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static TService Pick(this IEnumerable services, bool isOversea) where TService : IOverseaSupport @@ -45,6 +47,7 @@ internal static class EnumerableServiceExtension /// 服务提供器 /// 是否为海外服/Hoyolab /// 对应的服务 + [Obsolete("该方法会导致不必要的服务实例化")] public static TService PickRequiredService(this IServiceProvider serviceProvider, bool isOversea) where TService : IOverseaSupport { diff --git a/src/Snap.Hutao/Snap.Hutao/Model/Metadata/AvatarIds.cs b/src/Snap.Hutao/Snap.Hutao/Model/Metadata/AvatarIds.cs index 5f1c79ba..f01d436f 100644 --- a/src/Snap.Hutao/Snap.Hutao/Model/Metadata/AvatarIds.cs +++ b/src/Snap.Hutao/Snap.Hutao/Model/Metadata/AvatarIds.cs @@ -87,6 +87,9 @@ internal static class AvatarIds public static readonly AvatarId Mika = 10000080; public static readonly AvatarId Kaveh = 10000081; public static readonly AvatarId Baizhuer = 10000082; + public static readonly AvatarId Lynette = 10000083; + public static readonly AvatarId Lyney = 10000084; + public static readonly AvatarId Freminet = 10000085; /// /// 检查该角色是否为主角 diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/GachaLog/HutaoCloudViewModel.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/GachaLog/HutaoCloudViewModel.cs index f5782a07..32ce6b56 100644 --- a/src/Snap.Hutao/Snap.Hutao/ViewModel/GachaLog/HutaoCloudViewModel.cs +++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/GachaLog/HutaoCloudViewModel.cs @@ -114,17 +114,6 @@ internal sealed partial class HutaoCloudViewModel : Abstraction.ViewModel } } - private async Task RefreshUidCollectionAsync() - { - Response> resp = await hutaoCloudService.GetUidsAsync().ConfigureAwait(false); - - await taskContext.SwitchToMainThreadAsync(); - if (Options.IsCloudServiceAllowed = resp.IsOk()) - { - Uids = resp.Data!.ToObservableCollection(); - } - } - [Command("NavigateToSpiralAbyssRecordCommand")] private void NavigateToSpiralAbyssRecord() { @@ -138,4 +127,15 @@ internal sealed partial class HutaoCloudViewModel : Abstraction.ViewModel { await Windows.System.Launcher.LaunchUriAsync("https://afdian.net/item/80d3b9decf9011edb5f452540025c377".ToUri()); } + + private async Task RefreshUidCollectionAsync() + { + Response> resp = await hutaoCloudService.GetUidsAsync().ConfigureAwait(false); + + await taskContext.SwitchToMainThreadAsync(); + if (Options.IsCloudServiceAllowed = resp.IsOk()) + { + Uids = resp.Data!.ToObservableCollection(); + } + } } \ No newline at end of file