Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 修复启用 “启动时自动加速” 后,测试页面不显示问题 #3475

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,38 @@ public sealed partial class AcceleratorPageViewModel

public AcceleratorPageViewModel()
{
ProxyService.Current.WhenValueChanged(x => x.ProxyStatus)
.Where(x => x == true)
.Subscribe(_ =>
{
// Create new ProxyEnableDomain for 加速服务 page
var enableGroupDomain = ProxyService.Current.ProxyDomainsList
.Where(list => list.ThreeStateEnable == true || list.ThreeStateEnable == null)
.Select(list => new ProxyDomainGroupViewModel
{
Name = list.Name,
IconUrl = list.IconUrl ?? string.Empty,
EnableProxyDomainVMs = new(
list.Items!
.Where(i => i.ThreeStateEnable == true)
.Select(i => new ProxyDomainViewModel(i.Name, i.ProxyType, "https://" + i.ListenDomainNames.Split(";")[0],
i.Items?
.Select(c => new ProxyDomainViewModel(c.Name, c.ProxyType, "https://" + c.ListenDomainNames.Split(';')[0]))
.ToList()))
.ToList()),
})
.ToList();

EnableProxyDomainGroupVMs = enableGroupDomain.AsReadOnly();
});

StartProxyCommand = ReactiveCommand.CreateFromTask(async _ =>
{
#if LINUX
if (!EnvironmentCheck()) return;
#endif
//ProxyService.Current.ProxyStatus = !ProxyService.Current.ProxyStatus;
await ProxyService.Current.StartOrStopProxyService(!ProxyService.Current.ProxyStatus);

if (ProxyService.Current.ProxyStatus == false)
return;

// Create new ProxyEnableDomain for 加速服务 page
var enableGroupDomain = ProxyService.Current.ProxyDomainsList
.Where(list => list.ThreeStateEnable == true || list.ThreeStateEnable == null)
.Select(list => new ProxyDomainGroupViewModel
{
Name = list.Name,
IconUrl = list.IconUrl ?? string.Empty,
EnableProxyDomainVMs = new(
list.Items!
.Where(i => i.ThreeStateEnable == true)
.Select(i => new ProxyDomainViewModel(i.Name, i.ProxyType, "https://" + i.ListenDomainNames.Split(";")[0],
i.Items?
.Select(c => new ProxyDomainViewModel(c.Name, c.ProxyType, "https://" + c.ListenDomainNames.Split(';')[0]))
.ToList()))
.ToList()),
})
.ToList();

EnableProxyDomainGroupVMs = enableGroupDomain.AsReadOnly();
});

RefreshCommand = ReactiveCommand.Create(async () =>
Expand Down Expand Up @@ -110,8 +112,11 @@ public AcceleratorPageViewModel()
var configDns = ProxySettings.ProxyMasterDns.Value ?? string.Empty;
(delayMs, address) = await networkTestService.TestDNSAsync(testDomain, configDns, 53);
}
if (address.Length == 0)
throw new Exception("Parsing failed. Return empty ip address.");

DNSTestDelay = delayMs + "ms ";
DNSTestResult = "" + address.FirstOrDefault() ?? "0.0.0.0";
DNSTestResult = string.Empty + address.FirstOrDefault();
}
catch (Exception ex)
{
Expand Down
Loading