Compare commits

...

2 commits

Author SHA1 Message Date
2dust
67ffa810d3 Optimize code and remove Action
Some checks failed
release Linux / build (Release) (push) Has been cancelled
release macOS / build (Release) (push) Has been cancelled
release Windows desktop (Avalonia UI) / build (Release) (push) Has been cancelled
release Windows / build (Release) (push) Has been cancelled
2025-02-06 15:28:51 +08:00
2dust
ba2a636dd2 Fixed the system language judgment during the first run
https://github.com/2dust/v2rayN/issues/6638
2025-02-06 14:36:38 +08:00
3 changed files with 10 additions and 15 deletions

View file

@ -105,14 +105,9 @@ namespace ServiceLib.Handler
if (Utils.IsNullOrEmpty(config.UiItem.CurrentLanguage)) if (Utils.IsNullOrEmpty(config.UiItem.CurrentLanguage))
{ {
if (Thread.CurrentThread.CurrentCulture.Name.Equals("zh-cn", StringComparison.CurrentCultureIgnoreCase)) config.UiItem.CurrentLanguage = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.Equals("zh", StringComparison.CurrentCultureIgnoreCase)
{ ? Global.Languages.First()
config.UiItem.CurrentLanguage = Global.Languages.First(); : Global.Languages[2];
}
else
{
config.UiItem.CurrentLanguage = Global.Languages[2];
}
} }
config.ConstItem ??= new ConstItem(); config.ConstItem ??= new ConstItem();

View file

@ -243,7 +243,7 @@ namespace ServiceLib.Services
_updateFunc?.Invoke(true, string.Format(ResUI.MsgDownloadGeoFileSuccessfully, "geo")); _updateFunc?.Invoke(true, string.Format(ResUI.MsgDownloadGeoFileSuccessfully, "geo"));
} }
public async Task RunAvailabilityCheck(Action<bool, string> updateFunc) public async Task<string> RunAvailabilityCheck()
{ {
var downloadHandle = new DownloadService(); var downloadHandle = new DownloadService();
var time = await downloadHandle.RunAvailabilityCheck(null); var time = await downloadHandle.RunAvailabilityCheck(null);
@ -255,7 +255,7 @@ namespace ServiceLib.Services
ip = $"({ipInfo?.country_code}) {ipInfo?.ip}"; ip = $"({ipInfo?.country_code}) {ipInfo?.ip}";
} }
updateFunc?.Invoke(false, string.Format(ResUI.TestMeOutput, time, ip)); return string.Format(ResUI.TestMeOutput, time, ip);
} }
#region CheckUpdate private #region CheckUpdate private

View file

@ -311,11 +311,11 @@ namespace ServiceLib.ViewModels
{ {
return; return;
} }
await (new UpdateService()).RunAvailabilityCheck(async (bool success, string msg) =>
{ var msg = await (new UpdateService()).RunAvailabilityCheck();
NoticeHandler.Instance.SendMessageEx(msg);
_updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg); NoticeHandler.Instance.SendMessageEx(msg);
}); _updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg);
} }
public void TestServerAvailabilityResult(string msg) public void TestServerAvailabilityResult(string msg)