diff --git a/internal/web/actions/default/clusters/cluster/settings/dns/randomName.go b/internal/web/actions/default/clusters/cluster/settings/dns/randomName.go new file mode 100644 index 00000000..d35b1035 --- /dev/null +++ b/internal/web/actions/default/clusters/cluster/settings/dns/randomName.go @@ -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() +} diff --git a/internal/web/actions/default/clusters/cluster/settings/init.go b/internal/web/actions/default/clusters/cluster/settings/init.go index 85c98cb2..c58f58bc 100644 --- a/internal/web/actions/default/clusters/cluster/settings/init.go +++ b/internal/web/actions/default/clusters/cluster/settings/init.go @@ -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() }) } diff --git a/web/views/@default/clusters/cluster/settings/dns/index.html b/web/views/@default/clusters/cluster/settings/dns/index.html index 6afba29e..14e95c50 100644 --- a/web/views/@default/clusters/cluster/settings/dns/index.html +++ b/web/views/@default/clusters/cluster/settings/dns/index.html @@ -20,11 +20,11 @@ DNS子域名 *
- + .{{domain.name}} .主域名
-

当前集群的子域名,和主域名一起组成集群节点的子域名。

+

当前集群的子域名,和主域名一起组成集群节点的子域名。[随机生成]

diff --git a/web/views/@default/clusters/cluster/settings/dns/index.js b/web/views/@default/clusters/cluster/settings/dns/index.js index ea3086ee..3efea6fa 100644 --- a/web/views/@default/clusters/cluster/settings/dns/index.js +++ b/web/views/@default/clusters/cluster/settings/dns/index.js @@ -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 + }) + } }) \ No newline at end of file