From 2826444ffcfbab03a5e39b45989a49f220276653 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Mon, 8 Sep 2025 18:21:39 +0800 Subject: [PATCH] Code clean --- .../ViewModels/BackupAndRestoreViewModel.cs | 1 - .../ViewModels/ProfilesSelectViewModel.cs | 17 +++++------------ .../ViewModels/RoutingRuleSettingViewModel.cs | 1 + .../Views/ProfilesSelectWindow.axaml.cs | 7 +------ .../Views/RoutingRuleDetailsWindow.axaml.cs | 1 - .../v2rayN.Desktop/Views/SubEditWindow.axaml.cs | 1 - .../v2rayN/Views/ProfilesSelectWindow.xaml.cs | 6 +++--- v2rayN/v2rayN/Views/ProfilesView.xaml.cs | 2 +- .../Views/RoutingRuleDetailsWindow.xaml.cs | 1 - 9 files changed, 11 insertions(+), 26 deletions(-) diff --git a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs index 80336c5d..5a96a04d 100644 --- a/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/BackupAndRestoreViewModel.cs @@ -1,7 +1,6 @@ using System.Reactive; using ReactiveUI; using ReactiveUI.Fody.Helpers; -using Splat; namespace ServiceLib.ViewModels; diff --git a/v2rayN/ServiceLib/ViewModels/ProfilesSelectViewModel.cs b/v2rayN/ServiceLib/ViewModels/ProfilesSelectViewModel.cs index ff6d787f..8742755e 100644 --- a/v2rayN/ServiceLib/ViewModels/ProfilesSelectViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ProfilesSelectViewModel.cs @@ -1,27 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reactive; using System.Reactive.Linq; -using System.Text; -using System.Threading.Tasks; using DynamicData; using DynamicData.Binding; using ReactiveUI; using ReactiveUI.Fody.Helpers; -using Splat; namespace ServiceLib.ViewModels; + public class ProfilesSelectViewModel : MyReactiveObject { #region private prop - private List _lstProfile; private string _serverFilter = string.Empty; private Dictionary _dicHeaderSort = new(); private string _subIndexId = string.Empty; + // ConfigType filter state: default include-mode with all types selected private List _filterConfigTypes = new(); + private bool _filterExclude = false; #endregion private prop @@ -66,6 +61,7 @@ public class ProfilesSelectViewModel : MyReactiveObject _config = AppManager.Instance.Config; _updateView = updateView; _subIndexId = _config.SubIndexId ?? string.Empty; + #region WhenAnyValue && ReactiveCommand this.WhenAnyValue( @@ -130,6 +126,7 @@ public class ProfilesSelectViewModel : MyReactiveObject _updateView?.Invoke(EViewAction.CloseWindow, null); return true; } + #endregion Actions #region Servers && Groups @@ -168,7 +165,6 @@ public class ProfilesSelectViewModel : MyReactiveObject private async Task RefreshServersBiz() { var lstModel = await GetProfileItemsEx(_subIndexId, _serverFilter); - _lstProfile = JsonUtils.Deserialize>(JsonUtils.Serialize(lstModel)) ?? []; ProfileItems.Clear(); ProfileItems.AddRange(lstModel); @@ -211,9 +207,6 @@ public class ProfilesSelectViewModel : MyReactiveObject private async Task?> GetProfileItemsEx(string subid, string filter) { var lstModel = await AppManager.Instance.ProfileItems(_subIndexId, filter); - - //await ConfigHandler.SetDefaultServer(_config, lstModel); - lstModel = (from t in lstModel select new ProfileItemModel { diff --git a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs index f176e29b..4b192f04 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs @@ -13,6 +13,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject [Reactive] public RoutingItem SelectedRouting { get; set; } + public IObservableCollection RulesItems { get; } = new ObservableCollectionExtended(); [Reactive] diff --git a/v2rayN/v2rayN.Desktop/Views/ProfilesSelectWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/ProfilesSelectWindow.axaml.cs index 5df0251a..b3319154 100644 --- a/v2rayN/v2rayN.Desktop/Views/ProfilesSelectWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/ProfilesSelectWindow.axaml.cs @@ -1,17 +1,12 @@ -using System.Linq; using System.Reactive.Disposables; -using System.Threading.Tasks; using Avalonia; using Avalonia.Controls; -using Avalonia.Controls.Primitives; using Avalonia.Input; using Avalonia.Interactivity; -using Avalonia.Markup.Xaml; -using Avalonia.VisualTree; using Avalonia.ReactiveUI; +using Avalonia.VisualTree; using ReactiveUI; using ServiceLib.Manager; -using v2rayN.Desktop.Common; namespace v2rayN.Desktop.Views; diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs index 04b1219c..b19fc923 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs @@ -3,7 +3,6 @@ using Avalonia.Controls; using Avalonia.Interactivity; using ReactiveUI; using v2rayN.Desktop.Base; -using System.Threading.Tasks; namespace v2rayN.Desktop.Views; diff --git a/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml.cs index 486be1dd..d030ba02 100644 --- a/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml.cs @@ -3,7 +3,6 @@ using Avalonia; using Avalonia.Interactivity; using ReactiveUI; using v2rayN.Desktop.Base; -using System.Threading.Tasks; namespace v2rayN.Desktop.Views; diff --git a/v2rayN/v2rayN/Views/ProfilesSelectWindow.xaml.cs b/v2rayN/v2rayN/Views/ProfilesSelectWindow.xaml.cs index e9e33ec5..c6c82928 100644 --- a/v2rayN/v2rayN/Views/ProfilesSelectWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/ProfilesSelectWindow.xaml.cs @@ -3,10 +3,8 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Input; -using System.Windows.Threading; using ReactiveUI; using ServiceLib.Manager; -using Splat; using v2rayN.Base; namespace v2rayN.Views; @@ -34,7 +32,6 @@ public partial class ProfilesSelectWindow ViewModel = new ProfilesSelectViewModel(UpdateViewHandler); - this.WhenActivated(disposables => { this.OneWayBind(ViewModel, vm => vm.ProfileItems, v => v.lstProfiles.ItemsSource).DisposeWith(disposables); @@ -44,6 +41,8 @@ public partial class ProfilesSelectWindow this.Bind(ViewModel, vm => vm.SelectedSub, v => v.lstGroup.SelectedItem).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.ServerFilter, v => v.txtServerFilter.Text).DisposeWith(disposables); }); + + WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme); } public void AllowMultiSelect(bool allow) @@ -190,5 +189,6 @@ public partial class ProfilesSelectWindow // Trigger selection finalize when Confirm is clicked ViewModel?.SelectFinish(); } + #endregion Event } diff --git a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs index c03fb0bd..54e92181 100644 --- a/v2rayN/v2rayN/Views/ProfilesView.xaml.cs +++ b/v2rayN/v2rayN/Views/ProfilesView.xaml.cs @@ -119,7 +119,7 @@ public partial class ProfilesView if (obj is null) return false; WindowsUtils.SetClipboardData((string)obj); - break; + break; case EViewAction.ProfilesFocus: lstProfiles.Focus(); diff --git a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs index 806dde65..0c1d2a91 100644 --- a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs @@ -1,6 +1,5 @@ using System.Reactive.Disposables; using System.Windows; -using System.Windows.Threading; using ReactiveUI; using ServiceLib.Manager;