From d4550e240ca374e635c1c7f61941449423dc8423 Mon Sep 17 00:00:00 2001 From: TheWhiteDog9487 Date: Sat, 8 Aug 2026 11:57:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E9=83=A8=E5=88=86TryParse=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E7=9B=B4=E6=8E=A5=E5=AE=8C=E6=88=90=E6=98=A0=E5=B0=84?= =?UTF-8?q?=E7=9A=84=E7=B3=BB=E7=BB=9F=E8=BF=9B=E8=A1=8C=E7=89=B9=E5=88=A4?= =?UTF-8?q?=20=E8=99=BD=E7=84=B6=E7=8E=B0=E5=9C=A8=E5=8F=AA=E8=A6=81ArchLi?= =?UTF-8?q?nux=E4=B8=80=E4=B8=AA=EF=BC=8C=E4=BD=86=E4=B9=8B=E5=90=8E?= =?UTF-8?q?=E5=BA=94=E8=AF=A5=E4=BC=9A=E5=8F=98=E6=88=90=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- language.cs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/language.cs b/language.cs index 4d148a8..769d606 100644 --- a/language.cs +++ b/language.cs @@ -67,21 +67,24 @@ bool ExecuteCommand(string Command, 异常信息: {ExceptionMessage}"); }; WhenErrorThrown(ExitCode, string.Join("\n", StandardError), ExceptionInstance.Message); return false; } } - -if (Enum.TryParse(RuntimeInformation.OSDescription, out var CurrentSystem) == false){ - string CurrentSuppoetedLinuxDistributions = string.Join(", ", Enum.GetNames()); - string Message = @$" - 当前系统为 {RuntimeInformation.OSDescription} - 当前仅支持 {CurrentSuppoetedLinuxDistributions} - 强行使用可能会造成不可预知的问题 - 为避免出现故障,程序会强制退出 - 如果是误报,请在GitHub仓库打开一个新的issue。 - ".Trim(); - throw new NotSupportedException(Message); } +string OsDescription = RuntimeInformation.OSDescription; +if (Enum.TryParse(OsDescription.Split(' ')[0], out var CurrentSystem) == false){ + if (OsDescription.Contains("Arch Linux")){ + CurrentSystem = SupportedLinuxDistributions.ArchLinux; } + else{ + string CurrentSuppoetedLinuxDistributions = string.Join(", ", Enum.GetNames()); + string Message = @$" + 当前系统为 {OsDescription} + 当前仅支持 {CurrentSuppoetedLinuxDistributions} + 强行使用可能会造成不可预知的问题 + 为避免出现故障,程序会强制退出 + 如果是误报,请在GitHub仓库打开一个新的issue。 + ".Trim(); + throw new NotSupportedException(Message); } } if (GetEffectiveUserId() != 0){ throw new UnauthorizedAccessException("更改语言文件需要root权限,请使用sudo重新运行本程序"); } -Console.WriteLine($"探测到当前系统为 {RuntimeInformation.OSDescription}"); +Console.WriteLine($"探测到当前系统为 {OsDescription}"); switch (CurrentSystem){ case SupportedLinuxDistributions.Debian or SupportedLinuxDistributions.Armbian: { CheckUser();