集群可以单独设置WebP策略

This commit is contained in:
刘祥超
2022-04-01 16:42:08 +08:00
parent 53b1f07601
commit 8076fcd148
9 changed files with 188 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ package webp
import (
"encoding/json"
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/dao"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
@@ -44,6 +45,25 @@ func (this *IndexAction) RunGet(params struct {
this.Data["webId"] = webConfig.Id
this.Data["webpConfig"] = webConfig.WebP
// WebP策略配置
var serverMap = this.Data.GetMap("server")
var clusterId = serverMap.GetInt64("clusterId")
webpPolicyResp, err := this.RPC().NodeClusterRPC().FindEnabledNodeClusterWebPPolicy(this.AdminContext(), &pb.FindEnabledNodeClusterWebPPolicyRequest{NodeClusterId: clusterId})
if err != nil {
this.ErrorPage(err)
return
}
this.Data["requireCache"] = true
if len(webpPolicyResp.WebpPolicyJSON) > 0 {
var webpPolicy = &nodeconfigs.WebPImagePolicy{}
err = json.Unmarshal(webpPolicyResp.WebpPolicyJSON, webpPolicy)
if err != nil {
this.ErrorPage(err)
return
}
this.Data["requireCache"] = webpPolicy.RequireCache
}
this.Show()
}