From 39f80596003c6e8932a3d126aa6c1e6972bff270 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Wed, 19 Apr 2023 21:03:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=A8HTTP/1.x=E4=B8=8B?= =?UTF-8?q?=E5=BC=80=E5=A4=9A=E4=B8=AA=E7=AA=97=E5=8F=A3=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E9=9D=9E=E5=B8=B8=E6=85=A2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/admin_node_ext.go | 4 ++-- internal/web/actions/default/clusters/tasks/check.go | 5 ++++- internal/web/actions/default/dns/tasks/check.go | 5 ++++- web/public/js/vue.tea.js | 4 +++- web/views/@default/@layout.js | 8 ++++++-- web/views/@default/settings/server/updateHTTPPopup.html | 2 +- web/views/@default/settings/server/updateHTTPSPopup.html | 2 +- 7 files changed, 21 insertions(+), 9 deletions(-) diff --git a/internal/nodes/admin_node_ext.go b/internal/nodes/admin_node_ext.go index b4c99ed4..63b0555c 100644 --- a/internal/nodes/admin_node_ext.go +++ b/internal/nodes/admin_node_ext.go @@ -10,9 +10,9 @@ import ( // 启动IP库 func (this *AdminNode) startIPLibrary() { - logs.Println("NODE", "initializing ip library ...") + logs.Println("[NODE]initializing ip library ...") err := iplibrary.InitDefault() if err != nil { - logs.Println("NODE", "initialize ip library failed: "+err.Error()) + logs.Println("[NODE]initialize ip library failed: "+err.Error()) } } diff --git a/internal/web/actions/default/clusters/tasks/check.go b/internal/web/actions/default/clusters/tasks/check.go index 8f032de3..ad221951 100644 --- a/internal/web/actions/default/clusters/tasks/check.go +++ b/internal/web/actions/default/clusters/tasks/check.go @@ -15,6 +15,9 @@ func (this *CheckAction) RunPost(params struct { HasError bool IsUpdated bool }) { + var isStream = this.Request.ProtoMajor >= 2 + this.Data["isStream"] = isStream + var maxTries = 10 for i := 0; i < maxTries; i++ { resp, err := this.RPC().NodeTaskRPC().ExistsNodeTasks(this.AdminContext(), &pb.ExistsNodeTasksRequest{ @@ -26,7 +29,7 @@ func (this *CheckAction) RunPost(params struct { } // 如果没有数据变化,继续查询 - if i < maxTries-1 && params.IsUpdated && resp.ExistTasks == params.IsDoing && resp.ExistError == params.HasError { + if i < maxTries-1 && params.IsUpdated && resp.ExistTasks == params.IsDoing && resp.ExistError == params.HasError && isStream { time.Sleep(3 * time.Second) continue } diff --git a/internal/web/actions/default/dns/tasks/check.go b/internal/web/actions/default/dns/tasks/check.go index 843866a7..6cf86ee0 100644 --- a/internal/web/actions/default/dns/tasks/check.go +++ b/internal/web/actions/default/dns/tasks/check.go @@ -15,6 +15,9 @@ func (this *CheckAction) RunPost(params struct { HasError bool IsUpdated bool }) { + var isStream = this.Request.ProtoMajor >= 2 + this.Data["isStream"] = isStream + var maxTries = 10 for i := 0; i < maxTries; i++ { resp, err := this.RPC().DNSTaskRPC().ExistsDNSTasks(this.AdminContext(), &pb.ExistsDNSTasksRequest{}) @@ -24,7 +27,7 @@ func (this *CheckAction) RunPost(params struct { } // 如果没有数据变化,继续查询 - if i < maxTries-1 && params.IsUpdated && resp.ExistTasks == params.IsDoing && resp.ExistError == params.HasError { + if i < maxTries-1 && params.IsUpdated && resp.ExistTasks == params.IsDoing && resp.ExistError == params.HasError && isStream { time.Sleep(3 * time.Second) continue } diff --git a/web/public/js/vue.tea.js b/web/public/js/vue.tea.js index f208a7e5..721f956f 100644 --- a/web/public/js/vue.tea.js +++ b/web/public/js/vue.tea.js @@ -2312,7 +2312,9 @@ window.Tea.Action = function (action, params) { .then(function () { // console.log("done"); if (typeof (_doneFn) == "function") { - _doneFn.call(Tea.Vue, {}); + setTimeout(function () { + _doneFn.call(Tea.Vue, {}); + }) } }); }; diff --git a/web/views/@default/@layout.js b/web/views/@default/@layout.js index 66bce1b4..e662f26c 100644 --- a/web/views/@default/@layout.js +++ b/web/views/@default/@layout.js @@ -117,6 +117,7 @@ Tea.context(function () { if (!Tea.Vue.teaCheckNodeTasks) { return } + let isStream = false this.$post("/clusters/tasks/check") .params({ isDoing: this.doingNodeTasks.isDoing ? 1 : 0, @@ -128,11 +129,12 @@ Tea.context(function () { this.doingNodeTasks.isDoing = resp.data.isDoing this.doingNodeTasks.hasError = resp.data.hasError this.doingNodeTasks.isUpdated = true + isStream = resp.data.shouldWait }) .done(function () { this.$delay(function () { this.loadNodeTasks() - }, 5000) + }, isStream ? 5000 : 30000) }) } @@ -156,6 +158,7 @@ Tea.context(function () { if (!Tea.Vue.teaCheckDNSTasks) { return } + let isStream = false this.$post("/dns/tasks/check") .params({ isDoing: this.doingDNSTasks.isDoing ? 1 : 0, @@ -167,11 +170,12 @@ Tea.context(function () { this.doingDNSTasks.isDoing = resp.data.isDoing this.doingDNSTasks.hasError = resp.data.hasError this.doingDNSTasks.isUpdated = true + isStream = resp.data.isStream }) .done(function () { this.$delay(function () { this.loadDNSTasks() - }, 3000) + }, isStream ? 5000 : 30000) }) } diff --git a/web/views/@default/settings/server/updateHTTPPopup.html b/web/views/@default/settings/server/updateHTTPPopup.html index a6f3b372..c7b46c41 100644 --- a/web/views/@default/settings/server/updateHTTPPopup.html +++ b/web/views/@default/settings/server/updateHTTPPopup.html @@ -5,7 +5,7 @@
- +
是否启用启用HTTP
diff --git a/web/views/@default/settings/server/updateHTTPSPopup.html b/web/views/@default/settings/server/updateHTTPSPopup.html index 39ac02e9..a73af030 100644 --- a/web/views/@default/settings/server/updateHTTPSPopup.html +++ b/web/views/@default/settings/server/updateHTTPSPopup.html @@ -5,7 +5,7 @@ - +
是否启用启用HTTPS