mirror of
				https://github.com/2dust/v2rayN.git
				synced 2025-10-31 12:32:53 +00:00 
			
		
		
		
	treat index in menuRemoveDuplicateServer
This commit is contained in:
		
							parent
							
								
									9549d17b03
								
							
						
					
					
						commit
						56559e6509
					
				
					 2 changed files with 14 additions and 0 deletions
				
			
		|  | @ -627,12 +627,22 @@ namespace v2rayN.Forms | |||
| 
 | ||||
|         private void menuRemoveDuplicateServer_Click(object sender, EventArgs e) | ||||
|         { | ||||
|             VmessItem activeVm = null; | ||||
|             if (config.index >= 0) { | ||||
|                 activeVm = config.vmess[config.index]; | ||||
|             } | ||||
|             Utils.DedupServerList(config.vmess, out List<VmessItem> servers, config.keepOlderDedupl); | ||||
|             int oldCount = config.vmess.Count; | ||||
|             int newCount = servers.Count; | ||||
|             if (servers != null) | ||||
|             { | ||||
|                 config.vmess = servers; | ||||
| 
 | ||||
|                 if (activeVm != null) | ||||
|                 { | ||||
|                     int index = Utils.ServerVmIndexof(config.vmess, activeVm); | ||||
|                     if (index >= 0) config.index = index; // restore to the correct value | ||||
|                 } | ||||
|             } | ||||
|             //刷新 | ||||
|             RefreshServers(); | ||||
|  |  | |||
|  | @ -318,6 +318,10 @@ namespace v2rayN | |||
|             return $"{string.Format("{0:f1}", result)} {unit}"; | ||||
|         } | ||||
| 
 | ||||
|         public static int ServerVmIndexof(List<Mode.VmessItem> source, Mode.VmessItem findIt) | ||||
|         { | ||||
|             return source.IndexOf(findIt); | ||||
|         } | ||||
|         public static void DedupServerList(List<Mode.VmessItem> source, out List<Mode.VmessItem> result, bool keepOlder) | ||||
|         { | ||||
|             List<Mode.VmessItem> list = new List<Mode.VmessItem>(); | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 YFdyh000
						YFdyh000