对部分TryParse无法直接完成映射的系统进行特判

虽然现在只要ArchLinux一个,但之后应该会变成部分
This commit is contained in:
TheWhiteDog9487
2026-08-08 11:57:06 +08:00
parent 3493263324
commit d4550e240c
+15 -12
View File
@@ -67,21 +67,24 @@ bool ExecuteCommand(string Command,
异常信息: {ExceptionMessage}"); }; 异常信息: {ExceptionMessage}"); };
WhenErrorThrown(ExitCode, string.Join("\n", StandardError), ExceptionInstance.Message); WhenErrorThrown(ExitCode, string.Join("\n", StandardError), ExceptionInstance.Message);
return false; } } return false; } }
string OsDescription = RuntimeInformation.OSDescription;
if (Enum.TryParse<SupportedLinuxDistributions>(RuntimeInformation.OSDescription, out var CurrentSystem) == false){ if (Enum.TryParse<SupportedLinuxDistributions>(OsDescription.Split(' ')[0], out var CurrentSystem) == false){
string CurrentSuppoetedLinuxDistributions = string.Join(", ", Enum.GetNames<SupportedLinuxDistributions>()); if (OsDescription.Contains("Arch Linux")){
string Message = @$" CurrentSystem = SupportedLinuxDistributions.ArchLinux; }
当前系统为 {RuntimeInformation.OSDescription} else{
当前仅支持 {CurrentSuppoetedLinuxDistributions} string CurrentSuppoetedLinuxDistributions = string.Join(", ", Enum.GetNames<SupportedLinuxDistributions>());
强行使用可能会造成不可预知的问题 string Message = @$"
为避免出现故障,程序会强制退出 当前系统为 {OsDescription}
如果是误报,请在GitHub仓库打开一个新的issue。 当前仅支持 {CurrentSuppoetedLinuxDistributions}
".Trim(); 强行使用可能会造成不可预知的问题
throw new NotSupportedException(Message); } 为避免出现故障,程序会强制退出
如果是误报,请在GitHub仓库打开一个新的issue。
".Trim();
throw new NotSupportedException(Message); } }
if (GetEffectiveUserId() != 0){ if (GetEffectiveUserId() != 0){
throw new UnauthorizedAccessException("更改语言文件需要root权限,请使用sudo重新运行本程序"); } throw new UnauthorizedAccessException("更改语言文件需要root权限,请使用sudo重新运行本程序"); }
Console.WriteLine($"探测到当前系统为 {RuntimeInformation.OSDescription}"); Console.WriteLine($"探测到当前系统为 {OsDescription}");
switch (CurrentSystem){ switch (CurrentSystem){
case SupportedLinuxDistributions.Debian or SupportedLinuxDistributions.Armbian: { case SupportedLinuxDistributions.Debian or SupportedLinuxDistributions.Armbian: {
CheckUser(); CheckUser();