feat.在线安装器,更好的Issue与pull request模板。

This commit is contained in:
lincube
2026-06-03 00:50:52 +08:00
parent 29bd47986c
commit 28b06031f7
38 changed files with 2976 additions and 123 deletions

View File

@@ -0,0 +1,51 @@
namespace LanDesktopPLONDS.Installer.Services;
internal static class InstallerPlondsUrlResolver
{
public static IReadOnlyList<Uri> ResolveFilesZipUrls(
InstallerPlondsManifest manifest,
InstallerPlondsSource source)
{
var urls = new List<string?>();
var sourceKind = source.Kind.Trim().ToLowerInvariant();
if (sourceKind is "s3")
{
urls.Add(manifest.Downloads?.S3?.FilesZipUrl);
}
else if (sourceKind is "github")
{
urls.Add(manifest.Downloads?.GitHub?.FilesZipUrl);
}
urls.Add(DerivePackageUrl(source.ManifestUrl));
urls.Add(manifest.Downloads?.S3?.FilesZipUrl);
urls.Add(manifest.Downloads?.GitHub?.FilesZipUrl);
return urls
.Where(url => !string.IsNullOrWhiteSpace(url))
.Select(url => Uri.TryCreate(url, UriKind.Absolute, out var uri) ? uri : null)
.OfType<Uri>()
.Where(uri => uri.Scheme is "http" or "https")
.DistinctBy(uri => uri.AbsoluteUri, StringComparer.OrdinalIgnoreCase)
.ToArray();
}
private static string? DerivePackageUrl(string manifestUrl)
{
if (!Uri.TryCreate(manifestUrl, UriKind.Absolute, out var uri) ||
uri.Scheme is not ("http" or "https"))
{
return null;
}
var builder = new UriBuilder(uri);
var lastSlash = builder.Path.LastIndexOf('/');
builder.Path = lastSlash >= 0
? $"{builder.Path[..(lastSlash + 1)]}Files.zip"
: "Files.zip";
builder.Query = string.Empty;
builder.Fragment = string.Empty;
return builder.Uri.AbsoluteUri;
}
}