mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
add default background
This commit is contained in:
@@ -3,6 +3,12 @@
|
||||
|
||||
using Snap.Hutao.Control.Media;
|
||||
using Snap.Hutao.Core;
|
||||
using Snap.Hutao.Core.Caching;
|
||||
using Snap.Hutao.Core.IO;
|
||||
using Snap.Hutao.Service.Game.Scheme;
|
||||
using Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
using Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Content;
|
||||
using Snap.Hutao.Web.Response;
|
||||
using System.IO;
|
||||
using Windows.Graphics.Imaging;
|
||||
|
||||
@@ -14,14 +20,15 @@ internal sealed partial class BackgroundImageService : IBackgroundImageService
|
||||
{
|
||||
private static readonly HashSet<string> AllowedFormats = [".bmp", ".gif", ".ico", ".jpg", ".jpeg", ".png", ".tiff", ".webp"];
|
||||
|
||||
private readonly ITaskContext taskContext;
|
||||
private readonly IServiceProvider serviceProvider;
|
||||
private readonly RuntimeOptions runtimeOptions;
|
||||
private readonly ITaskContext taskContext;
|
||||
|
||||
private HashSet<string> backgroundPathMap;
|
||||
private HashSet<string> backgroundPathSet;
|
||||
|
||||
public async ValueTask<ValueResult<bool, BackgroundImage>> GetNextBackgroundImageAsync()
|
||||
{
|
||||
HashSet<string> backgroundSet = SkipOrInitBackground();
|
||||
HashSet<string> backgroundSet = await SkipOrInitBackgroundAsync().ConfigureAwait(false);
|
||||
|
||||
if (backgroundSet.Count <= 0)
|
||||
{
|
||||
@@ -49,18 +56,34 @@ internal sealed partial class BackgroundImageService : IBackgroundImageService
|
||||
}
|
||||
}
|
||||
|
||||
private HashSet<string> SkipOrInitBackground()
|
||||
private async ValueTask<HashSet<string>> SkipOrInitBackgroundAsync()
|
||||
{
|
||||
if (backgroundPathMap is null || backgroundPathMap.Count <= 0)
|
||||
if (backgroundPathSet is null || backgroundPathSet.Count <= 0)
|
||||
{
|
||||
string backgroundFolder = runtimeOptions.GetDataFolderBackgroundFolder();
|
||||
Directory.CreateDirectory(backgroundFolder);
|
||||
backgroundPathMap = Directory
|
||||
backgroundPathSet = Directory
|
||||
.GetFiles(backgroundFolder, "*.*", SearchOption.AllDirectories)
|
||||
.Where(path => AllowedFormats.Contains(Path.GetExtension(path)))
|
||||
.ToHashSet();
|
||||
|
||||
// No image found
|
||||
if (backgroundPathSet.Count <= 0)
|
||||
{
|
||||
ResourceClient resourceClient = serviceProvider.GetRequiredService<ResourceClient>();
|
||||
string launguageCode = serviceProvider.GetRequiredService<CultureOptions>().LanguageCode;
|
||||
LaunchScheme scheme = launguageCode is "zh-cn"
|
||||
? KnownLaunchSchemes.Get().First(scheme => !scheme.IsOversea && scheme.IsNotCompatOnly)
|
||||
: KnownLaunchSchemes.Get().First(scheme => scheme.IsOversea && scheme.IsNotCompatOnly);
|
||||
Response<GameContent> response = await resourceClient.GetContentAsync(scheme, launguageCode).ConfigureAwait(false);
|
||||
if (response is { Data.Advertisement.Background: string url })
|
||||
{
|
||||
ValueFile file = await serviceProvider.GetRequiredService<IImageCache>().GetFileFromCacheAsync(url.ToUri()).ConfigureAwait(false);
|
||||
backgroundPathSet = [file];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return backgroundPathMap;
|
||||
return backgroundPathSet;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ using Snap.Hutao.Model.Intrinsic;
|
||||
using Snap.Hutao.Service.Game.Package;
|
||||
using Snap.Hutao.View.Dialog;
|
||||
using Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
using Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
using Snap.Hutao.Web.Response;
|
||||
using System.IO;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ using Snap.Hutao.Core.IO;
|
||||
using Snap.Hutao.Core.IO.Hashing;
|
||||
using Snap.Hutao.Core.IO.Http.Sharding;
|
||||
using Snap.Hutao.Service.Game.Scheme;
|
||||
using Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
using Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
||||
xmlns:shwhshl="using:Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher"
|
||||
xmlns:shwhshlr="using:Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
d:DataContext="{d:DesignInstance shwhshl:Package}"
|
||||
d:DataContext="{d:DesignInstance shwhshlr:Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource.Package}"
|
||||
IsExpanded="True"
|
||||
ItemsSource="{Binding VoicePacks}"
|
||||
mc:Ignorable="d">
|
||||
@@ -24,7 +24,7 @@
|
||||
</cwc:SettingsExpander.Resources>
|
||||
|
||||
<cwc:SettingsExpander.ItemTemplate>
|
||||
<DataTemplate x:DataType="shwhshl:VoicePackage">
|
||||
<DataTemplate x:DataType="shwhshlr:VoicePackage">
|
||||
<cwc:SettingsCard
|
||||
Padding="{ThemeResource SettingsExpanderItemHasIconPadding}"
|
||||
ActionIcon="{shcm:FontIcon Glyph={StaticResource FontIconContentCopy}}"
|
||||
|
||||
@@ -18,6 +18,7 @@ using Snap.Hutao.Service.Game.Scheme;
|
||||
using Snap.Hutao.Service.Notification;
|
||||
using Snap.Hutao.Service.User;
|
||||
using Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
using Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
using System.Collections.Immutable;
|
||||
using System.IO;
|
||||
|
||||
|
||||
@@ -388,8 +388,8 @@ internal static class ApiEndpoints
|
||||
public static string SdkStaticLauncherContent(LaunchScheme scheme, string languageCode, bool advOnly = true)
|
||||
{
|
||||
return advOnly
|
||||
? $"{SdkStaticLauncherApi}/content?filter_adv=true&key={scheme.Key}&launcher_id={scheme.LauncherId}&launguage={languageCode}"
|
||||
: $"{SdkStaticLauncherApi}/content?key={scheme.Key}&launcher_id={scheme.LauncherId}&launguage={languageCode}";
|
||||
? $"{SdkStaticLauncherApi}/content?filter_adv=true&key={scheme.Key}&launcher_id={scheme.LauncherId}&language={languageCode}"
|
||||
: $"{SdkStaticLauncherApi}/content?key={scheme.Key}&launcher_id={scheme.LauncherId}&language={languageCode}";
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -298,17 +298,19 @@ internal static class ApiOsEndpoints
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SdkStaticLauncherApi
|
||||
#region SdkOsStaticLauncherApi
|
||||
|
||||
/// <summary>
|
||||
/// 启动器资源
|
||||
/// </summary>
|
||||
/// <param name="scheme">启动方案</param>
|
||||
/// <returns>启动器资源字符串</returns>
|
||||
public static string SdkOsStaticLauncherResource(LaunchScheme scheme)
|
||||
{
|
||||
return $"{SdkOsStaticLauncherApi}/resource?key={scheme.Key}&launcher_id={scheme.LauncherId}&channel_id={scheme.Channel:D}&sub_channel_id={scheme.SubChannel:D}";
|
||||
}
|
||||
|
||||
public static string SdkOsStaticLauncherContent(LaunchScheme scheme, string languageCode, bool advOnly = true)
|
||||
{
|
||||
return advOnly
|
||||
? $"{SdkOsStaticLauncherApi}/content?filter_adv=true&key={scheme.Key}&launcher_id={scheme.LauncherId}&language={languageCode}"
|
||||
: $"{SdkOsStaticLauncherApi}/content?key={scheme.Key}&launcher_id={scheme.LauncherId}&language={languageCode}";
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region WebApiOsAccountApi
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Content;
|
||||
|
||||
internal sealed class Advertisement
|
||||
{
|
||||
[JsonPropertyName("background")]
|
||||
public string Background { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("icon")]
|
||||
public string Icon { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("url")]
|
||||
public string Url { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("version")]
|
||||
public string Version { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("bg_checksum")]
|
||||
public string BackgroundChecksum { get; set; } = default!;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Content;
|
||||
|
||||
internal sealed class Banner
|
||||
{
|
||||
[JsonPropertyName("banner_id")]
|
||||
public string BannerId { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("img")]
|
||||
public string Image { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("url")]
|
||||
public string Url { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("order")]
|
||||
public string Order { get; set; } = default!;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Content;
|
||||
|
||||
internal sealed class GameContent
|
||||
{
|
||||
[JsonPropertyName("adv")]
|
||||
public Advertisement? Advertisement { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("banner")]
|
||||
public List<Banner> Banners { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("icon")]
|
||||
public List<Icon> Icons { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("post")]
|
||||
public List<Post> Posts { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("qq")]
|
||||
public List<QQ> QQs { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("more")]
|
||||
public More More { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("links")]
|
||||
public Link Links { get; set; } = default!;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Content;
|
||||
|
||||
internal sealed class Icon
|
||||
{
|
||||
[JsonPropertyName("icon_id")]
|
||||
public string IconId { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("img")]
|
||||
public string Image { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("url")]
|
||||
public string Url { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("qr_img")]
|
||||
public string QrImage { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("qr_desc")]
|
||||
public string QrDescription { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("img_hover")]
|
||||
public string ImageHover { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("other_links")]
|
||||
public List<IconLink> OtherLinks { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("title")]
|
||||
public string Title { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("icon_link")]
|
||||
public string IconLink { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("links")]
|
||||
public List<IconLink> Links { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("enable_red_dot")]
|
||||
public bool EnableRedDot { get; set; }
|
||||
|
||||
[JsonPropertyName("red_dot_content")]
|
||||
public string RedDotContent { get; set; } = default!;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
using Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient;
|
||||
using Snap.Hutao.Service.Game.Scheme;
|
||||
using Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
using Snap.Hutao.Web.Request.Builder;
|
||||
using Snap.Hutao.Web.Request.Builder.Abstraction;
|
||||
using Snap.Hutao.Web.Response;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
|
||||
internal sealed class IconLink
|
||||
{
|
||||
[JsonPropertyName("title")]
|
||||
public string Title { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("url")]
|
||||
public string Url { get; set; } = default!;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Content;
|
||||
|
||||
internal sealed class Link
|
||||
{
|
||||
[JsonPropertyName("faq")]
|
||||
public string FAQ { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("version")]
|
||||
public string Version { get; set; } = default!;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Content;
|
||||
|
||||
internal sealed class More
|
||||
{
|
||||
[JsonPropertyName("activity_link")]
|
||||
public string ActivityLink { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("announce_link")]
|
||||
public string AnnounceLink { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("info_link")]
|
||||
public string InfoLink { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("news_link")]
|
||||
public string NewsLink { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("trends_link")]
|
||||
public string TrendsLink { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("supply_link")]
|
||||
public string SupplyLink { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("tools_link")]
|
||||
public string ToolsLink { get; set; } = default!;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Content;
|
||||
|
||||
internal sealed class Post
|
||||
{
|
||||
[JsonPropertyName("post_id")]
|
||||
public string PostId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// POST_TYPE_ACTIVITY|POST_TYPE_ANNOUNCE|POST_TYPE_INFO
|
||||
/// </summary>
|
||||
[JsonPropertyName("type")]
|
||||
public string Type { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("url")]
|
||||
public string Url { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// MM/dd format
|
||||
/// </summary>
|
||||
[JsonPropertyName("show_time")]
|
||||
public string ShowTime { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("order")]
|
||||
public string Order { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("title")]
|
||||
public string Title { get; set; } = default!;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Content;
|
||||
|
||||
internal sealed class QQ
|
||||
{
|
||||
[JsonPropertyName("qq_id")]
|
||||
public string QQId { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("number")]
|
||||
public string Number { get; set; } = default!;
|
||||
|
||||
[JsonPropertyName("code")]
|
||||
public string Code { get; set; } = default!;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
|
||||
/// <summary>
|
||||
/// 差异文件
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
|
||||
/// <summary>
|
||||
/// 游戏
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
|
||||
/// <summary>
|
||||
/// 游戏资源
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
|
||||
internal sealed class LatestPackage : Package
|
||||
{
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
|
||||
/// <summary>
|
||||
/// 资源文件
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
|
||||
/// <summary>
|
||||
/// 最新客户端
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
|
||||
internal sealed class PackageSegment : PathMd5
|
||||
{
|
||||
@@ -4,7 +4,7 @@
|
||||
using Snap.Hutao.Core.IO.DataTransfer;
|
||||
using Snap.Hutao.Service.Notification;
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
|
||||
/// <summary>
|
||||
/// 下载的文件
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
|
||||
/// <summary>
|
||||
/// 插件
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
|
||||
/// <summary>
|
||||
/// 插件项
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
|
||||
/// <summary>
|
||||
/// Sdk
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
|
||||
/// <summary>
|
||||
/// 语音包
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
using Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient;
|
||||
using Snap.Hutao.Service.Game.Scheme;
|
||||
using Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Content;
|
||||
using Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher.Resource;
|
||||
using Snap.Hutao.Web.Request.Builder;
|
||||
using Snap.Hutao.Web.Request.Builder.Abstraction;
|
||||
using Snap.Hutao.Web.Response;
|
||||
@@ -60,4 +62,21 @@ internal sealed partial class ResourceClient
|
||||
|
||||
return Response.Response.DefaultIfNull(resp);
|
||||
}
|
||||
|
||||
public async ValueTask<Response<GameContent>> GetContentAsync(LaunchScheme scheme, string languageCode, bool advOnly = true, CancellationToken token = default)
|
||||
{
|
||||
string url = scheme.IsOversea
|
||||
? ApiOsEndpoints.SdkOsStaticLauncherContent(scheme, languageCode, advOnly)
|
||||
: ApiEndpoints.SdkStaticLauncherContent(scheme, languageCode, advOnly);
|
||||
|
||||
HttpRequestMessageBuilder builder = httpRequestMessageBuilderFactory.Create()
|
||||
.SetRequestUri(url)
|
||||
.Get();
|
||||
|
||||
Response<GameContent>? resp = await builder
|
||||
.TryCatchSendAsync<Response<GameContent>>(httpClient, logger, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return Response.Response.DefaultIfNull(resp);
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,11 @@ internal enum KnownReturnCode
|
||||
/// </summary>
|
||||
InvalidKey = -205,
|
||||
|
||||
/// <summary>
|
||||
/// 无效的参数
|
||||
/// </summary>
|
||||
ParameterError = -201,
|
||||
|
||||
/// <summary>
|
||||
/// 访问过于频繁
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user