From 57484471b735ada9dd2c72ccd359d1139e6f35bb Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Mon, 18 Apr 2022 18:19:30 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9B=86=E7=BE=A4DNS=E5=AD=90=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E5=8F=AF=E4=BB=A5=E9=9A=8F=E6=9C=BA=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cluster/settings/dns/randomName.go | 18 ++++++++++++++++++ .../default/clusters/cluster/settings/init.go | 2 +- .../clusters/cluster/settings/dns/index.html | 4 ++-- .../clusters/cluster/settings/dns/index.js | 7 +++++++ 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 internal/web/actions/default/clusters/cluster/settings/dns/randomName.go 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