mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 13:10:26 +08:00 
			
		
		
		
	添加域名时自动分割用逗号、顿号连接的域名列表
This commit is contained in:
		@@ -36,6 +36,12 @@ func (this *AddServerNamePopupAction) RunPost(params struct {
 | 
				
			|||||||
		// 去除空格
 | 
							// 去除空格
 | 
				
			||||||
		serverName = regexp.MustCompile(`\s+`).ReplaceAllString(serverName, "")
 | 
							serverName = regexp.MustCompile(`\s+`).ReplaceAllString(serverName, "")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 是否包含了多个域名
 | 
				
			||||||
 | 
							var splitReg = regexp.MustCompile(`([,、|,;|])`)
 | 
				
			||||||
 | 
							if splitReg.MatchString(serverName) {
 | 
				
			||||||
 | 
								params.ServerNames = strings.Join(splitReg.Split(serverName, -1), "\n")
 | 
				
			||||||
 | 
								params.Mode = "multiple"
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
			// 处理URL
 | 
								// 处理URL
 | 
				
			||||||
			if regexp.MustCompile(`^(?i)(http|https|ftp)://`).MatchString(serverName) {
 | 
								if regexp.MustCompile(`^(?i)(http|https|ftp)://`).MatchString(serverName) {
 | 
				
			||||||
				u, err := url.Parse(serverName)
 | 
									u, err := url.Parse(serverName)
 | 
				
			||||||
@@ -60,7 +66,13 @@ func (this *AddServerNamePopupAction) RunPost(params struct {
 | 
				
			|||||||
				"name": serverName,
 | 
									"name": serverName,
 | 
				
			||||||
				"type": "full",
 | 
									"type": "full",
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
	} else if params.Mode == "multiple" {
 | 
					
 | 
				
			||||||
 | 
								this.Success()
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if params.Mode == "multiple" {
 | 
				
			||||||
		if len(params.ServerNames) == 0 {
 | 
							if len(params.ServerNames) == 0 {
 | 
				
			||||||
			this.FailField("serverNames", "请输入至少域名")
 | 
								this.FailField("serverNames", "请输入至少域名")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -99,8 +111,6 @@ func (this *AddServerNamePopupAction) RunPost(params struct {
 | 
				
			|||||||
			"type":     "full",
 | 
								"type":     "full",
 | 
				
			||||||
			"subNames": serverNames,
 | 
								"subNames": serverNames,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		this.Fail("错误的mode参数")
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this.Success()
 | 
						this.Success()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user