mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-26 04:00:32 +08:00
支持批量添加域名、域名修改
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type AddServerNamePopupAction struct {
|
||||
@@ -19,17 +21,43 @@ func (this *AddServerNamePopupAction) RunGet(params struct{}) {
|
||||
}
|
||||
|
||||
func (this *AddServerNamePopupAction) RunPost(params struct {
|
||||
ServerName string
|
||||
Mode string
|
||||
|
||||
ServerName string
|
||||
ServerNames string
|
||||
|
||||
Must *actions.Must
|
||||
}) {
|
||||
params.Must.
|
||||
Field("serverName", params.ServerName).
|
||||
Require("请输入域名")
|
||||
if params.Mode == "single" {
|
||||
params.Must.
|
||||
Field("serverName", params.ServerName).
|
||||
Require("请输入域名")
|
||||
this.Data["serverName"] = maps.Map{
|
||||
"name": params.ServerName,
|
||||
"type": "full",
|
||||
}
|
||||
} else if params.Mode == "multiple" {
|
||||
if len(params.ServerNames) == 0 {
|
||||
this.FailField("serverNames", "请输入至少域名")
|
||||
}
|
||||
|
||||
this.Data["serverName"] = maps.Map{
|
||||
"name": params.ServerName,
|
||||
"type": "full",
|
||||
serverNames := []string{}
|
||||
for _, line := range strings.Split(params.ServerNames, "\n") {
|
||||
line := strings.TrimSpace(line)
|
||||
line = regexp.MustCompile(`\s+`).ReplaceAllString(line, "")
|
||||
if len(line) == 0 {
|
||||
continue
|
||||
}
|
||||
serverNames = append(serverNames, line)
|
||||
}
|
||||
this.Data["serverName"] = maps.Map{
|
||||
"name": "",
|
||||
"type": "full",
|
||||
"subNames": serverNames,
|
||||
}
|
||||
} else {
|
||||
this.Fail("错误的mode参数")
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user