Skip to content

Commit

Permalink
Merge pull request #3475 from BeyondDimension/fix_accelerator_by_startup
Browse files Browse the repository at this point in the history
🐛 修复启用 “启动时自动加速” 后,测试页面不显示问题
  • Loading branch information
rmbadmin authored Sep 23, 2024
2 parents 6ceaeb0 + a9e9134 commit de69402
Showing 1 changed file with 29 additions and 24 deletions.
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

0 comments on commit de69402

Please sign in to comment.