From 27284de0532dd693f6cddd8578795347012d0ef3 Mon Sep 17 00:00:00 2001 From: crazypeace Date: Sun, 24 Sep 2023 07:04:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E8=8A=82=E7=82=B9=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=97=B6,=20=E5=8E=BB=E9=99=A4=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 这个去重不会修改底层保存的节点数据, 只是在界面显示之前去重. 不影响现在的 菜单中的去重操作. (菜单中的去重操作是会修改底层保存的节点数据的) --- v2rayN/v2rayN/Handler/ConfigHandler.cs | 8 ++++- .../v2rayN/ViewModels/MainWindowViewModel.cs | 30 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/v2rayN/v2rayN/Handler/ConfigHandler.cs b/v2rayN/v2rayN/Handler/ConfigHandler.cs index 8bd6892d..b30d9ba2 100644 --- a/v2rayN/v2rayN/Handler/ConfigHandler.cs +++ b/v2rayN/v2rayN/Handler/ConfigHandler.cs @@ -889,7 +889,7 @@ namespace v2rayN.Handler return 0; } - private static bool CompareProfileItem(ProfileItem o, ProfileItem n, bool remarks) + public static bool CompareProfileItem(ProfileItem o, ProfileItem n, bool remarks) { if (o == null || n == null) { @@ -909,6 +909,12 @@ namespace v2rayN.Handler && (o.configType == EConfigType.Trojan || o.streamSecurity == n.streamSecurity) && o.flow == n.flow && o.sni == n.sni + && o.alpn == n.alpn + && o.allowInsecure == n.allowInsecure + && o.fingerprint == n.fingerprint + && o.publicKey == n.publicKey + && o.shortId == n.shortId + && o.spiderX == n.spiderX && (!remarks || o.remarks == n.remarks); } diff --git a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs index 84204192..2a6b1a23 100644 --- a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs @@ -765,7 +765,23 @@ namespace v2rayN.ViewModels _subId = SelectedSub?.id; _config.subIndexId = _subId; - RefreshServers(); + // RefreshServers(); + + // ȡڵб lstModel + List lstModel = LoadProfilelist(); + + // lstModel ڵȥ ޸ĵײ㱣Ľڵ + List lstKeep = new(); + foreach (ProfileItemModel item in lstModel) + { + if (!lstKeep.Exists(i => ConfigHandler.CompareProfileItem(i, item, false))) + { + lstKeep.Add(item); + } + } + + // ʾڵб lstModel + DisplayProfilelist(lstKeep); _updateView(EViewAction.ProfilesFocus); } @@ -784,9 +800,21 @@ namespace v2rayN.ViewModels } public void RefreshServers() + { + List lstModel = LoadProfilelist(); + + DisplayProfilelist(lstModel); + } + + private List LoadProfilelist() { List lstModel = LazyConfig.Instance.ProfileItems(_subId, _serverFilter); + return lstModel; + } + + private void DisplayProfilelist(List lstModel) + { ConfigHandler.SetDefaultServer(_config, lstModel); List lstServerStat = new();