From a40116d99106710495f08e10077d1a00fc6451f0 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Sun, 28 Apr 2024 22:10:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=95=86=E5=BA=97=E5=90=8C=E6=AD=A5=E5=9B=BE=E6=A0=87=E4=B8=A2?= =?UTF-8?q?=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98=20(#4776)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/app.go | 16 ++++++++++++++-- backend/cron/cron.go | 4 +++- backend/middleware/demo_handle.go | 3 +++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/backend/app/service/app.go b/backend/app/service/app.go index ee840f80d..6c60471b4 100644 --- a/backend/app/service/app.go +++ b/backend/app/service/app.go @@ -728,6 +728,14 @@ func (a AppService) GetAppUpdate() (*response.AppUpdateRes, error) { res.CanUpdate = true return res, err } + apps, _ := appRepo.GetBy(appRepo.WithResource(constant.AppResourceRemote)) + for _, app := range apps { + if app.Icon == "" { + res.CanUpdate = true + return res, err + } + } + list, err := getAppList() if err != nil { return res, err @@ -836,12 +844,16 @@ func (a AppService) SyncAppListFromRemote() (err error) { if err != nil { return err } - defer iconRes.Body.Close() body, err := io.ReadAll(iconRes.Body) if err != nil { return err } - iconStr := base64.StdEncoding.EncodeToString(body) + iconStr := "" + if !strings.Contains(string(body), "xml") { + iconStr = base64.StdEncoding.EncodeToString(body) + } + _ = iconRes.Body.Close() + app.Icon = iconStr app.TagsKey = l.AppProperty.Tags if l.AppProperty.Recommend > 0 { diff --git a/backend/cron/cron.go b/backend/cron/cron.go index b1ef463a5..93cb9c2c8 100644 --- a/backend/cron/cron.go +++ b/backend/cron/cron.go @@ -1,6 +1,8 @@ package cron import ( + "fmt" + mathRand "math/rand" "time" "github.com/1Panel-dev/1Panel/backend/app/model" @@ -41,7 +43,7 @@ func Run() { if _, err := global.Cron.AddJob("@daily", job.NewSSLJob()); err != nil { global.LOG.Errorf("can not add ssl corn job: %s", err.Error()) } - if _, err := global.Cron.AddJob("@daily", job.NewAppStoreJob()); err != nil { + if _, err := global.Cron.AddJob(fmt.Sprintf("%v %v * * *", mathRand.Intn(60), mathRand.Intn(3)), job.NewAppStoreJob()); err != nil { global.LOG.Errorf("can not add appstore corn job: %s", err.Error()) } diff --git a/backend/middleware/demo_handle.go b/backend/middleware/demo_handle.go index cb86c4016..f326dc9d2 100644 --- a/backend/middleware/demo_handle.go +++ b/backend/middleware/demo_handle.go @@ -27,6 +27,9 @@ var whiteUrlList = map[string]struct{}{ "/api/v1/databases/variables": {}, "/api/v1/databases/status": {}, "/api/v1/databases/baseinfo": {}, + + "/api/v1/waf/attack/stat": {}, + "/api/v1/waf/config/website": {}, } func DemoHandle() gin.HandlerFunc {