diff --git a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs index e88469d0..b4d9bb83 100644 --- a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs @@ -6,15 +6,15 @@ namespace ServiceLib.ViewModels { public class DNSSettingViewModel : MyReactiveObject { - [Reactive] public bool useSystemHosts { get; set; } - [Reactive] public string domainStrategy4Freedom { get; set; } - [Reactive] public string domainDNSAddress { get; set; } - [Reactive] public string normalDNS { get; set; } + [Reactive] public bool UseSystemHosts { get; set; } + [Reactive] public string DomainStrategy4Freedom { get; set; } + [Reactive] public string DomainDNSAddress { get; set; } + [Reactive] public string NormalDNS { get; set; } - [Reactive] public string domainStrategy4Freedom2 { get; set; } - [Reactive] public string domainDNSAddress2 { get; set; } - [Reactive] public string normalDNS2 { get; set; } - [Reactive] public string tunDNS2 { get; set; } + [Reactive] public string DomainStrategy4Freedom2 { get; set; } + [Reactive] public string DomainDNSAddress2 { get; set; } + [Reactive] public string NormalDNS2 { get; set; } + [Reactive] public string TunDNS2 { get; set; } public ReactiveCommand SaveCmd { get; } public ReactiveCommand ImportDefConfig4V2rayCmd { get; } @@ -31,14 +31,14 @@ namespace ServiceLib.ViewModels ImportDefConfig4V2rayCmd = ReactiveCommand.CreateFromTask(async () => { - normalDNS = EmbedUtils.GetEmbedText(Global.DNSV2rayNormalFileName); + NormalDNS = EmbedUtils.GetEmbedText(Global.DNSV2rayNormalFileName); await Task.CompletedTask; }); ImportDefConfig4SingboxCmd = ReactiveCommand.CreateFromTask(async () => { - normalDNS2 = EmbedUtils.GetEmbedText(Global.DNSSingboxNormalFileName); - tunDNS2 = EmbedUtils.GetEmbedText(Global.TunSingboxDNSFileName); + NormalDNS2 = EmbedUtils.GetEmbedText(Global.DNSSingboxNormalFileName); + TunDNS2 = EmbedUtils.GetEmbedText(Global.TunSingboxDNSFileName); await Task.CompletedTask; }); @@ -48,47 +48,47 @@ namespace ServiceLib.ViewModels private async Task Init() { var item = await AppHandler.Instance.GetDNSItem(ECoreType.Xray); - useSystemHosts = item.UseSystemHosts; - domainStrategy4Freedom = item?.DomainStrategy4Freedom ?? string.Empty; - domainDNSAddress = item?.DomainDNSAddress ?? string.Empty; - normalDNS = item?.NormalDNS ?? string.Empty; + UseSystemHosts = item.UseSystemHosts; + DomainStrategy4Freedom = item?.DomainStrategy4Freedom ?? string.Empty; + DomainDNSAddress = item?.DomainDNSAddress ?? string.Empty; + NormalDNS = item?.NormalDNS ?? string.Empty; var item2 = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box); - domainStrategy4Freedom2 = item2?.DomainStrategy4Freedom ?? string.Empty; - domainDNSAddress2 = item2?.DomainDNSAddress ?? string.Empty; - normalDNS2 = item2?.NormalDNS ?? string.Empty; - tunDNS2 = item2?.TunDNS ?? string.Empty; + DomainStrategy4Freedom2 = item2?.DomainStrategy4Freedom ?? string.Empty; + DomainDNSAddress2 = item2?.DomainDNSAddress ?? string.Empty; + NormalDNS2 = item2?.NormalDNS ?? string.Empty; + TunDNS2 = item2?.TunDNS ?? string.Empty; } private async Task SaveSettingAsync() { - if (normalDNS.IsNotEmpty()) + if (NormalDNS.IsNotEmpty()) { - var obj = JsonUtils.ParseJson(normalDNS); + var obj = JsonUtils.ParseJson(NormalDNS); if (obj != null && obj["servers"] != null) { } else { - if (normalDNS.Contains('{') || normalDNS.Contains('}')) + if (NormalDNS.Contains('{') || NormalDNS.Contains('}')) { NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText); return; } } } - if (normalDNS2.IsNotEmpty()) + if (NormalDNS2.IsNotEmpty()) { - var obj2 = JsonUtils.Deserialize(normalDNS2); + var obj2 = JsonUtils.Deserialize(NormalDNS2); if (obj2 == null) { NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText); return; } } - if (tunDNS2.IsNotEmpty()) + if (TunDNS2.IsNotEmpty()) { - var obj2 = JsonUtils.Deserialize(tunDNS2); + var obj2 = JsonUtils.Deserialize(TunDNS2); if (obj2 == null) { NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText); @@ -97,21 +97,21 @@ namespace ServiceLib.ViewModels } var item = await AppHandler.Instance.GetDNSItem(ECoreType.Xray); - item.DomainStrategy4Freedom = domainStrategy4Freedom; - item.DomainDNSAddress = domainDNSAddress; - item.UseSystemHosts = useSystemHosts; - item.NormalDNS = normalDNS; + item.DomainStrategy4Freedom = DomainStrategy4Freedom; + item.DomainDNSAddress = DomainDNSAddress; + item.UseSystemHosts = UseSystemHosts; + item.NormalDNS = NormalDNS; await ConfigHandler.SaveDNSItems(_config, item); var item2 = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box); - item2.DomainStrategy4Freedom = domainStrategy4Freedom2; - item2.DomainDNSAddress = domainDNSAddress2; - item2.NormalDNS = JsonUtils.Serialize(JsonUtils.ParseJson(normalDNS2)); - item2.TunDNS = JsonUtils.Serialize(JsonUtils.ParseJson(tunDNS2)); + item2.DomainStrategy4Freedom = DomainStrategy4Freedom2; + item2.DomainDNSAddress = DomainDNSAddress2; + item2.NormalDNS = JsonUtils.Serialize(JsonUtils.ParseJson(NormalDNS2)); + item2.TunDNS = JsonUtils.Serialize(JsonUtils.ParseJson(TunDNS2)); await ConfigHandler.SaveDNSItems(_config, item2); NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); - _updateView?.Invoke(EViewAction.CloseWindow, null); + _ = _updateView?.Invoke(EViewAction.CloseWindow, null); } } } diff --git a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs index b8c7805b..b494b9d1 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs @@ -18,13 +18,13 @@ namespace ServiceLib.ViewModels public IList SelectedSources { get; set; } [Reactive] - public string domainStrategy { get; set; } + public string DomainStrategy { get; set; } [Reactive] - public string domainMatcher { get; set; } + public string DomainMatcher { get; set; } [Reactive] - public string domainStrategy4Singbox { get; set; } + public string DomainStrategy4Singbox { get; set; } public ReactiveCommand RoutingAdvancedAddCmd { get; } public ReactiveCommand RoutingAdvancedRemoveCmd { get; } @@ -74,9 +74,9 @@ namespace ServiceLib.ViewModels { SelectedSource = new(); - domainStrategy = _config.RoutingBasicItem.DomainStrategy; - domainMatcher = _config.RoutingBasicItem.DomainMatcher; - domainStrategy4Singbox = _config.RoutingBasicItem.DomainStrategy4Singbox; + DomainStrategy = _config.RoutingBasicItem.DomainStrategy; + DomainMatcher = _config.RoutingBasicItem.DomainMatcher; + DomainStrategy4Singbox = _config.RoutingBasicItem.DomainStrategy4Singbox; await ConfigHandler.InitBuiltinRouting(_config); await RefreshRoutingItems(); @@ -91,11 +91,7 @@ namespace ServiceLib.ViewModels var routings = await AppHandler.Instance.RoutingItems(); foreach (var item in routings) { - bool def = false; - if (item.Id == _config.RoutingBasicItem.RoutingIndexId) - { - def = true; - } + var def = item.Id == _config.RoutingBasicItem.RoutingIndexId; var it = new RoutingItemModel() { @@ -114,9 +110,9 @@ namespace ServiceLib.ViewModels private async Task SaveRoutingAsync() { - _config.RoutingBasicItem.DomainStrategy = domainStrategy; - _config.RoutingBasicItem.DomainMatcher = domainMatcher; - _config.RoutingBasicItem.DomainStrategy4Singbox = domainStrategy4Singbox; + _config.RoutingBasicItem.DomainStrategy = DomainStrategy; + _config.RoutingBasicItem.DomainMatcher = DomainMatcher; + _config.RoutingBasicItem.DomainStrategy4Singbox = DomainStrategy4Singbox; if (await ConfigHandler.SaveConfig(_config) == 0) { diff --git a/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs index 3fd1099b..66863897 100644 --- a/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/DNSSettingWindow.axaml.cs @@ -36,15 +36,15 @@ namespace v2rayN.Desktop.Views this.WhenActivated(disposables => { - this.Bind(ViewModel, vm => vm.useSystemHosts, v => v.togUseSystemHosts.IsChecked).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.domainStrategy4Freedom, v => v.cmbdomainStrategy4Freedom.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.domainDNSAddress, v => v.cmbdomainDNSAddress.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.normalDNS, v => v.txtnormalDNS.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.UseSystemHosts, v => v.togUseSystemHosts.IsChecked).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.DomainStrategy4Freedom, v => v.cmbdomainStrategy4Freedom.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.DomainDNSAddress, v => v.cmbdomainDNSAddress.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.NormalDNS, v => v.txtnormalDNS.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.domainStrategy4Freedom2, v => v.cmbdomainStrategy4Out.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.domainDNSAddress2, v => v.cmbdomainDNSAddress2.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.normalDNS2, v => v.txtnormalDNS2.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.tunDNS2, v => v.txttunDNS2.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.DomainStrategy4Freedom2, v => v.cmbdomainStrategy4Out.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.DomainDNSAddress2, v => v.cmbdomainDNSAddress2.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.NormalDNS2, v => v.txtnormalDNS2.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.TunDNS2, v => v.txttunDNS2.Text).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.ImportDefConfig4V2rayCmd, v => v.btnImportDefConfig4V2ray).DisposeWith(disposables); diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml.cs index 4b89438d..1cadca91 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml.cs @@ -44,9 +44,9 @@ namespace v2rayN.Desktop.Views this.OneWayBind(ViewModel, vm => vm.RoutingItems, v => v.lstRoutings.ItemsSource).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource, v => v.lstRoutings.SelectedItem).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.domainStrategy, v => v.cmbdomainStrategy.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.domainMatcher, v => v.cmbdomainMatcher.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.domainStrategy4Singbox, v => v.cmbdomainStrategy4Singbox.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.DomainStrategy, v => v.cmbdomainStrategy.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.DomainMatcher, v => v.cmbdomainMatcher.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.DomainStrategy4Singbox, v => v.cmbdomainStrategy4Singbox.SelectedValue).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.RoutingAdvancedAddCmd, v => v.menuRoutingAdvancedAdd).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.RoutingAdvancedAddCmd, v => v.menuRoutingAdvancedAdd2).DisposeWith(disposables); diff --git a/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs index 2fadce70..252c56d6 100644 --- a/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/DNSSettingWindow.xaml.cs @@ -36,15 +36,15 @@ namespace v2rayN.Views this.WhenActivated(disposables => { - this.Bind(ViewModel, vm => vm.useSystemHosts, v => v.togUseSystemHosts.IsChecked).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.domainStrategy4Freedom, v => v.cmbdomainStrategy4Freedom.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.domainDNSAddress, v => v.cmbdomainDNSAddress.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.normalDNS, v => v.txtnormalDNS.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.UseSystemHosts, v => v.togUseSystemHosts.IsChecked).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.DomainStrategy4Freedom, v => v.cmbdomainStrategy4Freedom.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.DomainDNSAddress, v => v.cmbdomainDNSAddress.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.NormalDNS, v => v.txtnormalDNS.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.domainStrategy4Freedom2, v => v.cmbdomainStrategy4Out.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.domainDNSAddress2, v => v.cmbdomainDNSAddress2.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.normalDNS2, v => v.txtnormalDNS2.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.tunDNS2, v => v.txttunDNS2.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.DomainStrategy4Freedom2, v => v.cmbdomainStrategy4Out.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.DomainDNSAddress2, v => v.cmbdomainDNSAddress2.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.NormalDNS2, v => v.txtnormalDNS2.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.TunDNS2, v => v.txttunDNS2.Text).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.ImportDefConfig4V2rayCmd, v => v.btnImportDefConfig4V2ray).DisposeWith(disposables); diff --git a/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs b/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs index d8ea73b9..8eff2c05 100644 --- a/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/RoutingSettingWindow.xaml.cs @@ -39,9 +39,9 @@ namespace v2rayN.Views this.OneWayBind(ViewModel, vm => vm.RoutingItems, v => v.lstRoutings.ItemsSource).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource, v => v.lstRoutings.SelectedItem).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.domainStrategy, v => v.cmbdomainStrategy.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.domainMatcher, v => v.cmbdomainMatcher.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.domainStrategy4Singbox, v => v.cmbdomainStrategy4Singbox.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.DomainStrategy, v => v.cmbdomainStrategy.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.DomainMatcher, v => v.cmbdomainMatcher.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.DomainStrategy4Singbox, v => v.cmbdomainStrategy4Singbox.Text).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.RoutingAdvancedAddCmd, v => v.menuRoutingAdvancedAdd).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.RoutingAdvancedAddCmd, v => v.menuRoutingAdvancedAdd2).DisposeWith(disposables);