From 417b537de4a466f7b77be751fbc7b28c0c7b8245 Mon Sep 17 00:00:00 2001 From: DismissedLight <1686188646@qq.com> Date: Tue, 2 Jul 2024 22:28:01 +0800 Subject: [PATCH] unify achievement mvvm --- .../Service/Achievement/AchievementStatisticsService.cs | 2 +- .../Snap.Hutao/ViewModel/Abstraction/ViewModelSlim.cs | 2 +- .../ViewModel/Achievement/AchievementViewModelSlim.cs | 9 +-------- .../ViewModel/DailyNote/DailyNoteViewModelSlim.cs | 2 +- .../ViewModel/GachaLog/GachaLogViewModelSlim.cs | 2 +- .../ViewModel/GachaLog/HutaoCloudStatisticsViewModel.cs | 2 +- .../Snap.Hutao/ViewModel/Game/LaunchGameViewModelSlim.cs | 2 +- 7 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Achievement/AchievementStatisticsService.cs b/src/Snap.Hutao/Snap.Hutao/Service/Achievement/AchievementStatisticsService.cs index fc5d5e16..dd215fa7 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Achievement/AchievementStatisticsService.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Achievement/AchievementStatisticsService.cs @@ -8,7 +8,7 @@ using EntityAchievement = Snap.Hutao.Model.Entity.Achievement; namespace Snap.Hutao.Service.Achievement; [ConstructorGenerated] -[Injection(InjectAs.Scoped, typeof(IAchievementStatisticsService))] +[Injection(InjectAs.Transient, typeof(IAchievementStatisticsService))] internal sealed partial class AchievementStatisticsService : IAchievementStatisticsService { private const int AchievementCardTakeCount = 2; diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/Abstraction/ViewModelSlim.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/Abstraction/ViewModelSlim.cs index 787b16d3..4a8bac9e 100644 --- a/src/Snap.Hutao/Snap.Hutao/ViewModel/Abstraction/ViewModelSlim.cs +++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/Abstraction/ViewModelSlim.cs @@ -18,7 +18,7 @@ internal abstract partial class ViewModelSlim : ObservableObject protected IServiceProvider ServiceProvider { get => serviceProvider; } [Command("LoadCommand")] - protected virtual Task OpenUIAsync() + protected virtual Task LoadAsync() { return Task.CompletedTask; } diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/Achievement/AchievementViewModelSlim.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/Achievement/AchievementViewModelSlim.cs index 370404a8..59951e8a 100644 --- a/src/Snap.Hutao/Snap.Hutao/ViewModel/Achievement/AchievementViewModelSlim.cs +++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/Achievement/AchievementViewModelSlim.cs @@ -8,22 +8,15 @@ using Snap.Hutao.UI.Xaml.View.Page; namespace Snap.Hutao.ViewModel.Achievement; -/// -/// 简化的成就视图模型 -/// [ConstructorGenerated(CallBaseConstructor = true)] [Injection(InjectAs.Transient)] internal sealed partial class AchievementViewModelSlim : Abstraction.ViewModelSlim { private List? statisticsList; - /// - /// 统计列表 - /// public List? StatisticsList { get => statisticsList; set => SetProperty(ref statisticsList, value); } - /// - protected override async Task OpenUIAsync() + protected override async Task LoadAsync() { using (IServiceScope scope = ServiceProvider.CreateScope()) { diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/DailyNote/DailyNoteViewModelSlim.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/DailyNote/DailyNoteViewModelSlim.cs index 43b83037..a643d0c9 100644 --- a/src/Snap.Hutao/Snap.Hutao/ViewModel/DailyNote/DailyNoteViewModelSlim.cs +++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/DailyNote/DailyNoteViewModelSlim.cs @@ -31,7 +31,7 @@ internal sealed partial class DailyNoteViewModelSlim : Abstraction.ViewModelSlim public List? DailyNoteEntries { get => dailyNoteEntries; set => SetProperty(ref dailyNoteEntries, value); } /// - protected override async Task OpenUIAsync() + protected override async Task LoadAsync() { if (await metadataService.InitializeAsync().ConfigureAwait(false)) { diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/GachaLog/GachaLogViewModelSlim.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/GachaLog/GachaLogViewModelSlim.cs index 7bda4af3..e20c3b03 100644 --- a/src/Snap.Hutao/Snap.Hutao/ViewModel/GachaLog/GachaLogViewModelSlim.cs +++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/GachaLog/GachaLogViewModelSlim.cs @@ -25,7 +25,7 @@ internal sealed partial class GachaLogViewModelSlim : Abstraction.ViewModelSlim< public List? StatisticsList { get => statisticsList; set => SetProperty(ref statisticsList, value); } /// - protected override async Task OpenUIAsync() + protected override async Task LoadAsync() { using (IServiceScope scope = ServiceProvider.CreateScope()) { diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/GachaLog/HutaoCloudStatisticsViewModel.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/GachaLog/HutaoCloudStatisticsViewModel.cs index 164a366f..af838a76 100644 --- a/src/Snap.Hutao/Snap.Hutao/ViewModel/GachaLog/HutaoCloudStatisticsViewModel.cs +++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/GachaLog/HutaoCloudStatisticsViewModel.cs @@ -23,7 +23,7 @@ internal sealed partial class HutaoCloudStatisticsViewModel : Abstraction.ViewMo public HutaoStatistics? Statistics { get => statistics; set => SetProperty(ref statistics, value); } - protected override async Task OpenUIAsync() + protected override async Task LoadAsync() { await taskContext.SwitchToBackgroundAsync(); (bool isOk, HutaoStatistics statistics) = await hutaoCloudService.GetCurrentEventStatisticsAsync().ConfigureAwait(false); diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/Game/LaunchGameViewModelSlim.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/Game/LaunchGameViewModelSlim.cs index 692fad63..75d1defe 100644 --- a/src/Snap.Hutao/Snap.Hutao/ViewModel/Game/LaunchGameViewModelSlim.cs +++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/Game/LaunchGameViewModelSlim.cs @@ -40,7 +40,7 @@ internal sealed partial class LaunchGameViewModelSlim : Abstraction.ViewModelSli public GameAccount? SelectedGameAccount { get => selectedGameAccount; set => SetProperty(ref selectedGameAccount, value); } /// - protected override async Task OpenUIAsync() + protected override async Task LoadAsync() { LaunchScheme? scheme = launchGameShared.GetCurrentLaunchSchemeFromConfigFile(); ObservableCollection accounts = gameService.GameAccountCollection;