diff --git a/go.mod b/go.mod index 1b54bc2..c530896 100644 --- a/go.mod +++ b/go.mod @@ -34,6 +34,7 @@ require ( github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.385 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tms v1.0.385 github.com/tidwall/gjson v1.11.0 + github.com/vmihailenco/msgpack v4.0.4+incompatible github.com/x-cray/logrus-prefixed-formatter v0.5.2 github.com/yuin/goldmark v1.4.0 golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 @@ -118,7 +119,6 @@ require ( github.com/utahta/go-linenotify v0.5.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.1 // indirect - github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect diff --git a/http/a_resp.go b/http/a_resp.go index 6f408e2..8b9aa67 100644 --- a/http/a_resp.go +++ b/http/a_resp.go @@ -114,10 +114,14 @@ func GetApiPublicConfDataMap(c echo.Context) Map { imgUpload = true // 管理员始终允许上传图片 } - frontendConf := config.Instance.Frontend - if frontendConf == nil { - frontendConf = make(map[string]interface{}) + frontendConfSrc := config.Instance.Frontend + if frontendConfSrc == nil { + frontendConfSrc = make(map[string]interface{}) } + + frontendConf := make(map[string]interface{}) + CopyStruct(&frontendConfSrc, &frontendConf) + frontendConf["imgUpload"] = &imgUpload return Map{ diff --git a/http/utils.go b/http/utils.go index b7044bb..0532298 100644 --- a/http/utils.go +++ b/http/utils.go @@ -9,6 +9,7 @@ import ( "github.com/labstack/echo/v4" "github.com/mitchellh/mapstructure" "github.com/sirupsen/logrus" + "github.com/vmihailenco/msgpack" ) type Map = map[string]interface{} @@ -101,3 +102,15 @@ func CheckIsAllowed(c echo.Context, name string, email string, page model.Page, return true, nil } + +func CopyStruct(src *map[string]interface{}, dest *map[string]interface{}) error { + b, err := msgpack.Marshal(src) + if err != nil { + return err + } + err = msgpack.Unmarshal(b, dest) + if err != nil { + return err + } + return nil +}