mirror of
				https://github.com/MHSanaei/3x-ui.git
				synced 2025-10-30 20:02:51 +00:00 
			
		
		
		
	improve null handling
This commit is contained in:
		
							parent
							
								
									0917eb2742
								
							
						
					
					
						commit
						6af0d55ca9
					
				
					 1 changed files with 23 additions and 14 deletions
				
			
		|  | @ -1184,22 +1184,21 @@ | ||||||
|             deleteBalancer(index) { |             deleteBalancer(index) { | ||||||
|                 newTemplateSettings = this.templateSettings; |                 newTemplateSettings = this.templateSettings; | ||||||
| 
 | 
 | ||||||
|                 //remove from balancers |                 // Remove from balancers | ||||||
|                 const oldTag = this.balancersData[index].tag; |                 const removedBalancer = this.balancersData.splice(index, 1)[0]; | ||||||
|                 this.balancersData.splice(index, 1); |  | ||||||
| 
 | 
 | ||||||
|                 // remove from settings |                 // Remove from settings | ||||||
|                 let realIndex = newTemplateSettings.routing.balancers.findIndex((b) => b.tag == oldTag); |                 let realIndex = newTemplateSettings.routing.balancers.findIndex((b) => b.tag === removedBalancer.tag); | ||||||
|                 newTemplateSettings.routing.balancers.splice(realIndex, 1); |                 newTemplateSettings.routing.balancers.splice(realIndex, 1); | ||||||
| 
 | 
 | ||||||
|                 // remove related routing rules |                 // Remove related routing rules | ||||||
|                 let rules = []; |                 let rules = newTemplateSettings.routing.rules.filter((r) => !r.balancerTag || r.balancerTag !== removedBalancer.tag); | ||||||
|                 newTemplateSettings.routing.rules.forEach((r) => { |  | ||||||
|                     if (!r.balancerTag || r.balancerTag != oldTag) { |  | ||||||
|                         rules.push(r); |  | ||||||
|                     } |  | ||||||
|                 }); |  | ||||||
|                 newTemplateSettings.routing.rules = rules; |                 newTemplateSettings.routing.rules = rules; | ||||||
|  | 
 | ||||||
|  |                 // Update balancers property to an empty array if there are no more balancers | ||||||
|  |                 if (newTemplateSettings.routing.balancers.length === 0) { | ||||||
|  |                     delete newTemplateSettings.routing.balancers; | ||||||
|  |                 } | ||||||
|                 this.templateSettings = newTemplateSettings; |                 this.templateSettings = newTemplateSettings; | ||||||
|             }, |             }, | ||||||
|             addReverse(){ |             addReverse(){ | ||||||
|  | @ -2025,7 +2024,13 @@ | ||||||
|                 }, |                 }, | ||||||
|                 set: function (newValue) { |                 set: function (newValue) { | ||||||
|                     newTemplateSettings = this.templateSettings; |                     newTemplateSettings = this.templateSettings; | ||||||
|                     newTemplateSettings.dns =  newValue ? { servers: [], queryStrategy: "UseIP", tag: "dns_inbound" } : null; |                     if (newValue) { | ||||||
|  |                         newTemplateSettings.dns = { servers: [], queryStrategy: "UseIP", tag: "dns_inbound" }; | ||||||
|  |                         newTemplateSettings.fakedns = null;  | ||||||
|  |                     } else { | ||||||
|  |                         delete newTemplateSettings.dns; | ||||||
|  |                         delete newTemplateSettings.fakedns; | ||||||
|  |                     } | ||||||
|                     this.templateSettings = newTemplateSettings; |                     this.templateSettings = newTemplateSettings; | ||||||
|                 } |                 } | ||||||
|             }, |             }, | ||||||
|  | @ -2061,7 +2066,11 @@ | ||||||
|                 get: function () { return this.templateSettings && this.templateSettings.fakedns ? this.templateSettings.fakedns : []; }, |                 get: function () { return this.templateSettings && this.templateSettings.fakedns ? this.templateSettings.fakedns : []; }, | ||||||
|                 set: function (newValue) { |                 set: function (newValue) { | ||||||
|                     newTemplateSettings = this.templateSettings; |                     newTemplateSettings = this.templateSettings; | ||||||
|                     newTemplateSettings.fakedns = newValue.length >0 ? newValue : null; |                     if (this.enableDNS) { | ||||||
|  |                         newTemplateSettings.fakedns = newValue.length > 0 ? newValue : null; | ||||||
|  |                     } else { | ||||||
|  |                         delete newTemplateSettings.fakedns; | ||||||
|  |                     } | ||||||
|                     this.templateSettings = newTemplateSettings; |                     this.templateSettings = newTemplateSettings; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 MHSanaei
						MHSanaei