mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-20 15:44:25 +08:00
98 lines
3.3 KiB
C#
98 lines
3.3 KiB
C#
using System;
|
|
|
|
namespace LanMountainDesktop.Services;
|
|
|
|
public static class UpdateSettingsValues
|
|
{
|
|
public const string ChannelStable = "stable";
|
|
public const string ChannelPreview = "preview";
|
|
|
|
public const string ModeManual = "manual";
|
|
public const string ModeDownloadThenConfirm = "download_then_confirm";
|
|
public const string ModeSilentOnExit = "silent_on_exit";
|
|
public const string ModeSilentDownload = ModeDownloadThenConfirm;
|
|
public const string ModeSilentInstall = ModeSilentOnExit;
|
|
|
|
// NOTE: keep constant name for compatibility with existing call sites.
|
|
public const string DownloadSourcePlonds = "plonds-api";
|
|
public const string DownloadSourcePdc = DownloadSourcePlonds;
|
|
public const string DownloadSourceStcn = DownloadSourcePlonds;
|
|
public const string LegacyDownloadSourcePlonds = "pdc";
|
|
public const string LegacyDownloadSourcePdc = LegacyDownloadSourcePlonds;
|
|
public const string LegacyDownloadSourceStcn = "stcn";
|
|
public const string DownloadSourceGitHub = "github";
|
|
public const string DownloadSourceGhProxy = "gh-proxy";
|
|
public const string PlondsStaticBaseUrlEnvironmentVariable = "LANMOUNTAIN_UPDATE_BASE_URL";
|
|
public const string DefaultPlondsStaticBaseUrl = "https://cn-nb1.rains3.com/lmdesktop/lanmountain/update";
|
|
|
|
public const int DefaultDownloadThreads = 4;
|
|
public const int MinDownloadThreads = 1;
|
|
public const int MaxDownloadThreads = 128;
|
|
public const string DefaultGhProxyBaseUrl = "https://gh-proxy.com/";
|
|
|
|
public static string NormalizeChannel(string? value, bool includePrereleaseFallback = false)
|
|
{
|
|
if (string.Equals(value, ChannelPreview, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return ChannelPreview;
|
|
}
|
|
|
|
if (string.Equals(value, ChannelStable, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return ChannelStable;
|
|
}
|
|
|
|
return includePrereleaseFallback ? ChannelPreview : ChannelStable;
|
|
}
|
|
|
|
public static string NormalizeMode(string? value)
|
|
{
|
|
if (string.Equals(value, ModeManual, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return ModeManual;
|
|
}
|
|
|
|
if (string.Equals(value, ModeSilentOnExit, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return ModeSilentOnExit;
|
|
}
|
|
|
|
return ModeDownloadThenConfirm;
|
|
}
|
|
|
|
public static string NormalizeDownloadSource(string? value)
|
|
{
|
|
if (string.Equals(value, LegacyDownloadSourcePlonds, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return DownloadSourcePlonds;
|
|
}
|
|
|
|
if (string.Equals(value, LegacyDownloadSourceStcn, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return DownloadSourcePlonds;
|
|
}
|
|
|
|
if (string.Equals(value, DownloadSourcePlonds, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return DownloadSourcePlonds;
|
|
}
|
|
|
|
if (string.Equals(value, DownloadSourceGhProxy, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return DownloadSourceGhProxy;
|
|
}
|
|
|
|
if (string.Equals(value, DownloadSourceGitHub, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return DownloadSourceGitHub;
|
|
}
|
|
|
|
return DownloadSourcePlonds;
|
|
}
|
|
|
|
public static int NormalizeDownloadThreads(int value)
|
|
{
|
|
return Math.Clamp(value, MinDownloadThreads, MaxDownloadThreads);
|
|
}
|
|
}
|