diff --git a/src/Snap.Hutao/Snap.Hutao.Installer/Package.wxs b/src/Snap.Hutao/Snap.Hutao.Installer/Package.wxs index b269725..77afbb1 100644 --- a/src/Snap.Hutao/Snap.Hutao.Installer/Package.wxs +++ b/src/Snap.Hutao/Snap.Hutao.Installer/Package.wxs @@ -2,7 +2,7 @@ diff --git a/src/Snap.Hutao/Snap.Hutao/Model/Metadata/Avatar/AvatarIds.cs b/src/Snap.Hutao/Snap.Hutao/Model/Metadata/Avatar/AvatarIds.cs index 96a9f93..885aadd 100644 --- a/src/Snap.Hutao/Snap.Hutao/Model/Metadata/Avatar/AvatarIds.cs +++ b/src/Snap.Hutao/Snap.Hutao/Model/Metadata/Avatar/AvatarIds.cs @@ -126,6 +126,9 @@ internal static class AvatarIds public static readonly AvatarId Nefer = 10000122; public static readonly AvatarId Durin = 10000123; public static readonly AvatarId Jahoda = 10000124; + public static readonly AvatarId Columbina = 10000125; + public static readonly AvatarId Zibai = 10000126; + public static readonly AvatarId Illuga = 10000127; private static readonly FrozenSet StandardWishIds = [ diff --git a/src/Snap.Hutao/Snap.Hutao/Model/Metadata/Weapon/WeaponIds.cs b/src/Snap.Hutao/Snap.Hutao/Model/Metadata/Weapon/WeaponIds.cs index a933b8d..38d8533 100644 --- a/src/Snap.Hutao/Snap.Hutao/Model/Metadata/Weapon/WeaponIds.cs +++ b/src/Snap.Hutao/Snap.Hutao/Model/Metadata/Weapon/WeaponIds.cs @@ -22,9 +22,8 @@ internal static class WeaponIds 11401U, 11402U, 11403U, 11405U, 12401U, 12402U, 12403U, 12405U, 13401U, 13407U, - 14401U, 14402U, 14403U, 14409U, - 15401U, 15402U, 15403U, 15405U, - 15434U + 14401U, 14402U, 14403U, 14409U, 14433U, 14434U, + 15401U, 15402U, 15403U, 15405U, 15434U ]; public static readonly FrozenSet OrangeStandardWishIds = @@ -34,7 +33,8 @@ internal static class WeaponIds 13502U, 13505U, 14501U, 14502U, 15501U, 15502U, - 15515U, 11518U + 15515U, 11518U, + 14522U, 11519U ]; public static bool IsOrangeStandardWish(in WeaponId weaponId) diff --git a/src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj b/src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj index 6eb2a91..248cb3f 100644 --- a/src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj +++ b/src/Snap.Hutao/Snap.Hutao/Snap.Hutao.csproj @@ -11,7 +11,7 @@ true False - 1.18.1.0 + 1.18.2.0 False False diff --git a/src/Snap.Hutao/Snap.Hutao/ViewModel/Game/LaunchGameViewModel.cs b/src/Snap.Hutao/Snap.Hutao/ViewModel/Game/LaunchGameViewModel.cs index 95ff3ae..4a01c89 100644 --- a/src/Snap.Hutao/Snap.Hutao/ViewModel/Game/LaunchGameViewModel.cs +++ b/src/Snap.Hutao/Snap.Hutao/ViewModel/Game/LaunchGameViewModel.cs @@ -1,4 +1,5 @@ // Copyright (c) DGP Studio. All rights reserved. +// Copyright (c) Millennium-Science-Technology-R-D-Inst. All rights reserved. // Licensed under the MIT license. using Snap.Hutao.Core.ExceptionService; @@ -129,12 +130,39 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel, IView await HandleGamePathEntryChangeAsync().ConfigureAwait(false); Shared.ResumeLaunchExecutionAsync(this).SafeForget(); - // 初始化第三方工具列表 + // 初始化第三方工具列表(不阻塞页面加载) + _ = InitializeThirdPartyToolsInBackgroundAsync(token); + + return true; + } + + private async Task InitializeThirdPartyToolsInBackgroundAsync(CancellationToken token) + { try { - ImmutableArray tools = await InitializeThirdPartyToolsAsync().ConfigureAwait(false); - SentrySdk.AddBreadcrumb($"Initialized {tools.Length} third party tools", category: "ThirdPartyTool"); - thirdPartyToolsField.Value = tools; + // Yield to let navigation/UI finish first. + await Task.Yield(); + + if (token.IsCancellationRequested || IsViewUnloaded.Value) + { + return; + } + + ImmutableArray tools = await InitializeThirdPartyToolsAsync(token).ConfigureAwait(false); + + if (token.IsCancellationRequested || IsViewUnloaded.Value) + { + return; + } + + await taskContext.SwitchToMainThreadAsync(); + if (!token.IsCancellationRequested && !IsViewUnloaded.Value) + { + thirdPartyToolsField.Value = tools; + } + } + catch (OperationCanceledException) + { } catch (Exception ex) { @@ -142,7 +170,8 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel, IView SentrySdk.CaptureException(ex); } - return true; + + } [Command("IdentifyMonitorsCommand")] @@ -337,19 +366,26 @@ internal sealed partial class LaunchGameViewModel : Abstraction.ViewModel, IView } } - private async ValueTask> InitializeThirdPartyToolsAsync() + private async ValueTask> InitializeThirdPartyToolsAsync(CancellationToken token) { try { SentrySdk.AddBreadcrumb("Starting to initialize third party tools", category: "ThirdPartyTool"); IThirdPartyToolService thirdPartyToolService = serviceProvider.GetRequiredService(); SentrySdk.AddBreadcrumb("Got IThirdPartyToolService instance", category: "ThirdPartyTool"); - + + // Note: service API is not cancellable; we only honor cancellation before/after the call. + token.ThrowIfCancellationRequested(); ImmutableArray tools = await thirdPartyToolService.GetToolsAsync().ConfigureAwait(false); + token.ThrowIfCancellationRequested(); + SentrySdk.AddBreadcrumb($"Got {tools.Length} tools from service", category: "ThirdPartyTool"); - return tools; } + catch (OperationCanceledException) + { + return ImmutableArray.Empty; + } catch (Exception ex) { SentrySdk.AddBreadcrumb($"Failed to initialize third party tools: {ex.Message}", category: "ThirdPartyTool");