mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
fix game resouce latest package no path
This commit is contained in:
@@ -13,7 +13,7 @@ internal sealed class Game
|
||||
/// 最新客户端
|
||||
/// </summary>
|
||||
[JsonPropertyName("latest")]
|
||||
public Package Latest { get; set; } = default!;
|
||||
public LatestPackage Latest { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// 相对于当前版本的之前版本的差异文件(非预下载)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
|
||||
internal sealed class LatestPackage : Package
|
||||
{
|
||||
[JsonPropertyName("segments")]
|
||||
public List<PackageSegment> Segments { get; set; } = default!;
|
||||
}
|
||||
@@ -45,8 +45,6 @@ internal class Package : PathMd5
|
||||
[JsonPropertyName("decompressed_path")]
|
||||
public string DecompressedPath { get; set; } = default!;
|
||||
|
||||
// We don't want to support `segments` downloading
|
||||
|
||||
/// <summary>
|
||||
/// 包大小 bytes
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
|
||||
internal sealed class PackageSegment : PathMd5
|
||||
{
|
||||
[JsonPropertyName("package_size")]
|
||||
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
|
||||
public long PackageSize { get; set; } = default!;
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
using Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient;
|
||||
using Snap.Hutao.Service.Game;
|
||||
using Snap.Hutao.Web.Response;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.SdkStatic.Hk4e.Launcher;
|
||||
@@ -36,6 +37,13 @@ internal sealed partial class ResourceClient
|
||||
.TryCatchGetFromJsonAsync<Response<GameResource>>(url, options, logger, token)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
// 补全缺失的信息
|
||||
if (response is { Data.Game.Latest: LatestPackage latest })
|
||||
{
|
||||
latest.Path = latest.Segments[0].Path[..^4];
|
||||
latest.Name = Path.GetFileName(latest.Path);
|
||||
}
|
||||
|
||||
return Response.Response.DefaultIfNull(response);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user