diff --git a/internal/web/actions/default/servers/components/cache/init.go b/internal/web/actions/default/servers/components/cache/init.go index 4326ef57..79b33b9a 100644 --- a/internal/web/actions/default/servers/components/cache/init.go +++ b/internal/web/actions/default/servers/components/cache/init.go @@ -28,7 +28,7 @@ func init() { Post("/testWrite", new(TestWriteAction)). Get("/selectPopup", new(SelectPopupAction)). Post("/count", new(CountAction)). - + Post("/updateRefs", new(UpdateRefsAction)). EndAll() }) } diff --git a/internal/web/actions/default/servers/components/cache/updateRefs.go b/internal/web/actions/default/servers/components/cache/updateRefs.go new file mode 100644 index 00000000..c28ed145 --- /dev/null +++ b/internal/web/actions/default/servers/components/cache/updateRefs.go @@ -0,0 +1,35 @@ +// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved. + +package cache + +import ( + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" +) + +type UpdateRefsAction struct { + actionutils.ParentAction +} + +func (this *UpdateRefsAction) Init() { + this.Nav("", "", "") +} + +func (this *UpdateRefsAction) RunPost(params struct { + CachePolicyId int64 + RefsJSON []byte +}) { + // 修改缓存条件 + if params.CachePolicyId > 0 && len(params.RefsJSON) > 0 { + _, err := this.RPC().HTTPCachePolicyRPC().UpdateHTTPCachePolicyRefs(this.AdminContext(), &pb.UpdateHTTPCachePolicyRefsRequest{ + HttpCachePolicyId: params.CachePolicyId, + RefsJSON: params.RefsJSON, + }) + if err != nil { + this.ErrorPage(err) + return + } + } + + this.Success() +} diff --git a/web/public/js/components/server/http-cache-config-box.js b/web/public/js/components/server/http-cache-config-box.js index 19d05519..1db206b9 100644 --- a/web/public/js/components/server/http-cache-config-box.js +++ b/web/public/js/components/server/http-cache-config-box.js @@ -56,7 +56,7 @@ Vue.component("http-cache-config-box", {