From 95919f592c0c40417dc8e6d6a8de3ae784ae8fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=A5=E6=B5=B7?= Date: Tue, 26 Dec 2023 21:43:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/script/controller.go | 4 ++++ api/tencent/controller.go | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/api/script/controller.go b/api/script/controller.go index a0345e72..4961b8aa 100644 --- a/api/script/controller.go +++ b/api/script/controller.go @@ -1,6 +1,8 @@ package script import ( + "strings" + "github.com/gin-gonic/gin" "tdp-cloud/model/script" @@ -67,6 +69,7 @@ func (*Controller) create(c *gin.Context) { } rq.UserId = c.GetUint("UserId") + rq.Content = strings.TrimSpace(rq.Content) if id, err := script.Create(rq); err == nil { c.Set("Payload", gin.H{"Id": id}) @@ -94,6 +97,7 @@ func (*Controller) update(c *gin.Context) { } rq.UserId = c.GetUint("UserId") + rq.Content = strings.TrimSpace(rq.Content) if err := script.Update(rq); err == nil { c.Set("Message", "更新成功") diff --git a/api/tencent/controller.go b/api/tencent/controller.go index ca84a027..d561710d 100644 --- a/api/tencent/controller.go +++ b/api/tencent/controller.go @@ -1,7 +1,7 @@ package tencent import ( - "io/ioutil" + "io" "net/http" "github.com/gin-gonic/gin" @@ -66,7 +66,7 @@ func (*Controller) vncProxy(c *gin.Context) { return } - if res, err := ioutil.ReadAll(resp.Body); err == nil { + if res, err := io.ReadAll(resp.Body); err == nil { c.Set("HTML", string(res)) } else { c.Set("Error", err) diff --git a/go.mod b/go.mod index 0a63f4d9..a7e4db30 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/knadh/koanf/providers/file v0.1.0 github.com/knadh/koanf/v2 v2.0.1 // 辅助类库 - github.com/opentdp/go-helper v0.5.3 + github.com/opentdp/go-helper v0.5.4 // 计划任务 github.com/robfig/cron/v3 v3.0.1 // Go 官方模块 diff --git a/go.sum b/go.sum index 4ff6cbeb..ad3cdbe4 100644 --- a/go.sum +++ b/go.sum @@ -187,8 +187,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/opentdp/go-helper v0.5.3 h1:J4mLgNY/g5yBk1vv1yQ0FgT/OZioDflKQ/Kdh1NymiQ= -github.com/opentdp/go-helper v0.5.3/go.mod h1:9m+t/2x1CmjZ9YQP37+xECCO84eqMnsxnRE/7y37GjE= +github.com/opentdp/go-helper v0.5.4 h1:OA+CcXpqMokVdjPsZwNAhQfG6SjLqNdds72A3DXy9qc= +github.com/opentdp/go-helper v0.5.4/go.mod h1:9m+t/2x1CmjZ9YQP37+xECCO84eqMnsxnRE/7y37GjE= github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI= github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=