集群DNS子域名可以随机生成

This commit is contained in:
刘祥超
2022-04-18 18:19:30 +08:00
parent 6afecb5708
commit caf9eeae2e
4 changed files with 28 additions and 3 deletions

View File

@@ -0,0 +1,18 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package dns
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/iwind/TeaGo/rands"
)
type RandomNameAction struct {
actionutils.ParentAction
}
func (this *RandomNameAction) RunPost(params struct{}) {
this.Data["name"] = "cluster" + rands.HexString(8)
this.Success()
}

View File

@@ -39,6 +39,7 @@ func init() {
// DNS
Prefix("/clusters/cluster/settings/dns").
GetPost("", new(dns.IndexAction)).
Post("/randomName", new(dns.RandomNameAction)).
// 消息
Prefix("/clusters/cluster/settings/message").
@@ -78,7 +79,6 @@ func init() {
// WebP
Prefix("/clusters/cluster/settings/webp").
GetPost("", new(webp.IndexAction)).
EndAll()
})
}

View File

@@ -20,11 +20,11 @@
<td class="title">DNS子域名 *</td>
<td>
<div class="ui input right labeled">
<input type="text" name="dnsName" maxlength="64" style="width:10em" v-model="dnsName"/>
<input type="text" name="dnsName" maxlength="64" style="width:12em" v-model="dnsName"/>
<span class="ui label" v-if="domain != null && domain.name != null && domain.name.length > 0">.{{domain.name}}</span>
<span class="ui label" v-else>.主域名</span>
</div>
<p class="comment">当前集群的子域名,和主域名一起组成集群节点的子域名。</p>
<p class="comment">当前集群的子域名,和主域名一起组成集群节点的子域名。<a href="" @click.prevent="generateRandName()">[随机生成]</a></p>
</td>
</tr>
<tr>

View File

@@ -10,4 +10,11 @@ Tea.context(function () {
this.addCnameRecord = function (name) {
this.$refs.cnameRecords.addValue(name)
}
this.generateRandName = function () {
this.$post(".randomName")
.success(function (resp) {
this.dnsName = resp.data.name
})
}
})