mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
shell interop
This commit is contained in:
@@ -19,17 +19,11 @@ internal sealed class HttpClientGenerator : IIncrementalGenerator
|
||||
{
|
||||
private const string AttributeName = "Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient.HttpClientAttribute";
|
||||
|
||||
private const string DefaultName = "Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient.HttpClientConfiguration.Default";
|
||||
private const string XRpcName = "Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient.HttpClientConfiguration.XRpc";
|
||||
private const string XRpc2Name = "Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient.HttpClientConfiguration.XRpc2";
|
||||
private const string XRpc3Name = "Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient.HttpClientConfiguration.XRpc3";
|
||||
|
||||
private const string HttpClientConfiguration = "Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient.HttpClientConfiguration.";
|
||||
private const string PrimaryHttpMessageHandlerAttributeName = "Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient.PrimaryHttpMessageHandlerAttribute";
|
||||
private const string UseDynamicSecretAttributeName = "Snap.Hutao.Web.Hoyolab.DynamicSecret.UseDynamicSecretAttribute";
|
||||
private const string CRLF = "\r\n";
|
||||
|
||||
private static readonly DiagnosticDescriptor invalidConfigurationDescriptor = new("SH100", "无效的 HttpClientConfiguration", "尚未支持生成 {0} 配置", "Quality", DiagnosticSeverity.Error, true);
|
||||
|
||||
public void Initialize(IncrementalGeneratorInitializationContext context)
|
||||
{
|
||||
IncrementalValueProvider<ImmutableArray<GeneratorSyntaxContext2>> injectionClasses = context.SyntaxProvider
|
||||
@@ -109,26 +103,7 @@ internal sealed class HttpClientGenerator : IIncrementalGenerator
|
||||
}
|
||||
|
||||
lineBuilder.Append($"{context.Symbol.ToDisplayString()}>(");
|
||||
|
||||
string configurationName = arguments[0].ToCSharpString();
|
||||
switch (configurationName)
|
||||
{
|
||||
case DefaultName:
|
||||
lineBuilder.Append("DefaultConfiguration)");
|
||||
break;
|
||||
case XRpcName:
|
||||
lineBuilder.Append("XRpcConfiguration)");
|
||||
break;
|
||||
case XRpc2Name:
|
||||
lineBuilder.Append("XRpc2Configuration)");
|
||||
break;
|
||||
case XRpc3Name:
|
||||
lineBuilder.Append("XRpc3Configuration)");
|
||||
break;
|
||||
default:
|
||||
production.ReportDiagnostic(Diagnostic.Create(invalidConfigurationDescriptor, null, configurationName));
|
||||
break;
|
||||
}
|
||||
lineBuilder.Append(arguments[0].ToCSharpString().Substring(HttpClientConfiguration.Length)).Append("Configuration)");
|
||||
|
||||
if (context.SingleOrDefaultAttribute(PrimaryHttpMessageHandlerAttributeName) is AttributeData handlerData)
|
||||
{
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using CommunityToolkit.WinUI.Notifications;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.Windows.AppLifecycle;
|
||||
using Snap.Hutao.Core;
|
||||
using Snap.Hutao.Core.ExceptionService;
|
||||
using Snap.Hutao.Core.LifeCycle;
|
||||
using Snap.Hutao.Core.Shell;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Snap.Hutao;
|
||||
@@ -56,7 +56,7 @@ public sealed partial class App : Application
|
||||
activation.InitializeWith(firstInstance);
|
||||
|
||||
LogDiagnosticInformation();
|
||||
PostLaunchAsync().SafeForget(logger);
|
||||
serviceProvider.GetRequiredService<IJumpListInterop>().ConfigureAsync().SafeForget();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -72,11 +72,6 @@ public sealed partial class App : Application
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task PostLaunchAsync()
|
||||
{
|
||||
await JumpListHelper.ConfigureAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void LogDiagnosticInformation()
|
||||
{
|
||||
HutaoOptions hutaoOptions = serviceProvider.GetRequiredService<HutaoOptions>();
|
||||
|
||||
16
src/Snap.Hutao/Snap.Hutao/Core/Shell/IJumpListInterop.cs
Normal file
16
src/Snap.Hutao/Snap.Hutao/Core/Shell/IJumpListInterop.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Core.Shell;
|
||||
|
||||
/// <summary>
|
||||
/// 跳转列表交互
|
||||
/// </summary>
|
||||
internal interface IJumpListInterop
|
||||
{
|
||||
/// <summary>
|
||||
/// 异步配置跳转列表
|
||||
/// </summary>
|
||||
/// <returns>任务</returns>
|
||||
Task ConfigureAsync();
|
||||
}
|
||||
23
src/Snap.Hutao/Snap.Hutao/Core/Shell/IScheduleTaskInterop.cs
Normal file
23
src/Snap.Hutao/Snap.Hutao/Core/Shell/IScheduleTaskInterop.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Core.Shell;
|
||||
|
||||
/// <summary>
|
||||
/// 任务计划互操作
|
||||
/// </summary>
|
||||
internal interface IScheduleTaskInterop
|
||||
{
|
||||
/// <summary>
|
||||
/// 注册实时便笺刷新任务
|
||||
/// </summary>
|
||||
/// <param name="interval">间隔(秒)</param>
|
||||
/// <returns>是否注册或修改成功</returns>
|
||||
bool RegisterForDailyNoteRefresh(int interval);
|
||||
|
||||
/// <summary>
|
||||
/// 卸载全部注册的任务
|
||||
/// </summary>
|
||||
/// <returns>是否卸载成功</returns>
|
||||
bool UnregisterAllTasks();
|
||||
}
|
||||
@@ -4,19 +4,20 @@
|
||||
using Snap.Hutao.Core.LifeCycle;
|
||||
using Windows.UI.StartScreen;
|
||||
|
||||
namespace Snap.Hutao.Core;
|
||||
namespace Snap.Hutao.Core.Shell;
|
||||
|
||||
/// <summary>
|
||||
/// 跳转列表帮助类
|
||||
/// 跳转列表交互
|
||||
/// </summary>
|
||||
[HighQuality]
|
||||
internal static class JumpListHelper
|
||||
[Injection(InjectAs.Transient, typeof(IJumpListInterop))]
|
||||
internal sealed class JumpListInterop : IJumpListInterop
|
||||
{
|
||||
/// <summary>
|
||||
/// 异步配置跳转列表
|
||||
/// </summary>
|
||||
/// <returns>任务</returns>
|
||||
public static async Task ConfigureAsync()
|
||||
public async Task ConfigureAsync()
|
||||
{
|
||||
if (JumpList.IsSupported())
|
||||
{
|
||||
@@ -6,13 +6,14 @@ using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Windows.Storage;
|
||||
|
||||
namespace Snap.Hutao.Core;
|
||||
namespace Snap.Hutao.Core.Shell;
|
||||
|
||||
/// <summary>
|
||||
/// 任务计划器服务
|
||||
/// 任务计划互操作
|
||||
/// </summary>
|
||||
[HighQuality]
|
||||
internal static class ScheduleTaskHelper
|
||||
[Injection(InjectAs.Transient, typeof(IScheduleTaskInterop))]
|
||||
internal sealed class ScheduleTaskInterop : IScheduleTaskInterop
|
||||
{
|
||||
private const string DailyNoteRefreshTaskName = "SnapHutaoDailyNoteRefreshTask";
|
||||
|
||||
@@ -21,7 +22,7 @@ internal static class ScheduleTaskHelper
|
||||
/// </summary>
|
||||
/// <param name="interval">间隔(秒)</param>
|
||||
/// <returns>是否注册或修改成功</returns>
|
||||
public static bool RegisterForDailyNoteRefresh(int interval)
|
||||
public bool RegisterForDailyNoteRefresh(int interval)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -43,7 +44,7 @@ internal static class ScheduleTaskHelper
|
||||
/// 卸载全部注册的任务
|
||||
/// </summary>
|
||||
/// <returns>是否卸载成功</returns>
|
||||
public static bool UnregisterAllTasks()
|
||||
public bool UnregisterAllTasks()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -74,4 +75,4 @@ internal static class ScheduleTaskHelper
|
||||
|
||||
return fullName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Core;
|
||||
using Snap.Hutao.Core.Shell;
|
||||
using Snap.Hutao.Model;
|
||||
using Snap.Hutao.Model.Entity;
|
||||
using Snap.Hutao.Service.Abstraction;
|
||||
@@ -16,6 +16,7 @@ namespace Snap.Hutao.Service.DailyNote;
|
||||
internal sealed class DailyNoteOptions : DbStoreOptions
|
||||
{
|
||||
private readonly IServiceProvider serviceProvider;
|
||||
private readonly IScheduleTaskInterop scheduleTaskInterop;
|
||||
private readonly List<NameValue<int>> refreshTimes = new()
|
||||
{
|
||||
new(SH.ViewModelDailyNoteRefreshTime4, 240),
|
||||
@@ -36,6 +37,7 @@ internal sealed class DailyNoteOptions : DbStoreOptions
|
||||
public DailyNoteOptions(IServiceProvider serviceProvider)
|
||||
: base(serviceProvider)
|
||||
{
|
||||
scheduleTaskInterop = serviceProvider.GetRequiredService<IScheduleTaskInterop>();
|
||||
this.serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
@@ -54,7 +56,7 @@ internal sealed class DailyNoteOptions : DbStoreOptions
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
if (ScheduleTaskHelper.RegisterForDailyNoteRefresh(value.Value))
|
||||
if (scheduleTaskInterop.RegisterForDailyNoteRefresh(value.Value))
|
||||
{
|
||||
SetOption(ref selectedRefreshTime, SettingEntry.DailyNoteRefreshSeconds, value, value => value.Value.ToString());
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Snap.Hutao.Service.Metadata;
|
||||
/// 元数据服务
|
||||
/// </summary>
|
||||
[HighQuality]
|
||||
[SuppressMessage("", "SA1124")]
|
||||
internal interface IMetadataService : ICastableService
|
||||
{
|
||||
/// <summary>
|
||||
@@ -26,6 +27,8 @@ internal interface IMetadataService : ICastableService
|
||||
/// <returns>初始化是否成功</returns>
|
||||
ValueTask<bool> InitializeAsync();
|
||||
|
||||
#region RawData
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取成就列表
|
||||
/// </summary>
|
||||
@@ -40,6 +43,13 @@ internal interface IMetadataService : ICastableService
|
||||
/// <returns>成就分类列表</returns>
|
||||
ValueTask<List<AchievementGoal>> GetAchievementGoalsAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取角色突破列表
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>角色突破列表</returns>
|
||||
ValueTask<List<Promote>> GetAvatarPromotesAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取角色列表
|
||||
/// </summary>
|
||||
@@ -47,13 +57,6 @@ internal interface IMetadataService : ICastableService
|
||||
/// <returns>角色列表</returns>
|
||||
ValueTask<List<Avatar>> GetAvatarsAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取装备被动Id到圣遗物套装的映射
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>装备被动Id到圣遗物套装的映射</returns>
|
||||
ValueTask<Dictionary<EquipAffixId, ReliquarySet>> GetEquipAffixIdToReliquarySetMapAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取卡池配置列表
|
||||
/// </summary>
|
||||
@@ -61,6 +64,79 @@ internal interface IMetadataService : ICastableService
|
||||
/// <returns>卡池配置列表</returns>
|
||||
ValueTask<List<GachaEvent>> GetGachaEventsAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取材料列表
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>材料列表</returns>
|
||||
ValueTask<List<Material>> GetMaterialsAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取怪物列表
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>怪物列表</returns>
|
||||
ValueTask<List<Monster>> GetMonstersAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取圣遗物列表
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>圣遗物列表</returns>
|
||||
ValueTask<List<Reliquary>> GetReliquariesAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取圣遗物强化属性列表
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>圣遗物强化属性列表</returns>
|
||||
ValueTask<List<ReliquaryAffix>> GetReliquaryAffixesAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取圣遗物等级数据
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>圣遗物等级数据</returns>
|
||||
ValueTask<List<ReliquaryLevel>> GetReliquaryLevelsAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取圣遗物主属性强化属性列表
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>圣遗物强化属性列表</returns>
|
||||
ValueTask<List<ReliquaryMainAffix>> GetReliquaryMainAffixesAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取圣遗物套装
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>圣遗物套装列表</returns>
|
||||
ValueTask<List<ReliquarySet>> GetReliquarySetsAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取武器突破列表
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>武器突破列表</returns>
|
||||
ValueTask<List<Promote>> GetWeaponPromotesAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取武器列表
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>武器列表</returns>
|
||||
ValueTask<List<Weapon>> GetWeaponsAsync(CancellationToken token = default);
|
||||
#endregion
|
||||
|
||||
#region IdDataMap
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取装备被动Id到圣遗物套装的映射
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>装备被动Id到圣遗物套装的映射</returns>
|
||||
ValueTask<Dictionary<EquipAffixId, ReliquarySet>> GetEquipAffixIdToReliquarySetMapAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取成就映射
|
||||
/// </summary>
|
||||
@@ -109,6 +185,9 @@ internal interface IMetadataService : ICastableService
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>Id到武器的字典</returns>
|
||||
ValueTask<Dictionary<WeaponId, Weapon>> GetIdToWeaponMapAsync(CancellationToken token = default);
|
||||
#endregion
|
||||
|
||||
#region NameDataMap
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取名称到角色的字典
|
||||
@@ -123,62 +202,9 @@ internal interface IMetadataService : ICastableService
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>名称到武器的字典</returns>
|
||||
ValueTask<Dictionary<string, Weapon>> GetNameToWeaponMapAsync(CancellationToken token = default);
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取圣遗物列表
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>圣遗物列表</returns>
|
||||
ValueTask<List<Reliquary>> GetReliquariesAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取圣遗物强化属性列表
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>圣遗物强化属性列表</returns>
|
||||
ValueTask<List<ReliquaryAffix>> GetReliquaryAffixesAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取圣遗物等级数据
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>圣遗物等级数据</returns>
|
||||
ValueTask<List<ReliquaryLevel>> GetReliquaryLevelsAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取圣遗物主属性强化属性列表
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>圣遗物强化属性列表</returns>
|
||||
ValueTask<List<ReliquaryMainAffix>> GetReliquaryMainAffixesAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取武器列表
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>武器列表</returns>
|
||||
ValueTask<List<Weapon>> GetWeaponsAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取圣遗物套装
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>圣遗物套装列表</returns>
|
||||
ValueTask<List<ReliquarySet>> GetReliquarySetsAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取材料列表
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>材料列表</returns>
|
||||
ValueTask<List<Material>> GetMaterialsAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取怪物列表
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>怪物列表</returns>
|
||||
ValueTask<List<Monster>> GetMonstersAsync(CancellationToken token = default);
|
||||
#region LevelCurveMap
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取等级角色曲线映射
|
||||
@@ -200,18 +226,5 @@ internal interface IMetadataService : ICastableService
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>等级武器曲线映射</returns>
|
||||
ValueTask<Dictionary<int, Dictionary<GrowCurveType, float>>> GetLevelToWeaponCurveMapAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取角色突破列表
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>角色突破列表</returns>
|
||||
ValueTask<List<Promote>> GetAvatarPromotesAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取武器突破列表
|
||||
/// </summary>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>武器突破列表</returns>
|
||||
ValueTask<List<Promote>> GetWeaponPromotesAsync(CancellationToken token = default);
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user