Browse Source

fix: 解决应用商店同步图标丢失的问题 (#4776)

pull/4790/head
zhengkunwang 7 months ago committed by GitHub
parent
commit
a40116d991
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 16
      backend/app/service/app.go
  2. 4
      backend/cron/cron.go
  3. 3
      backend/middleware/demo_handle.go

16
backend/app/service/app.go

@ -728,6 +728,14 @@ func (a AppService) GetAppUpdate() (*response.AppUpdateRes, error) {
res.CanUpdate = true res.CanUpdate = true
return res, err 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() list, err := getAppList()
if err != nil { if err != nil {
return res, err return res, err
@ -836,12 +844,16 @@ func (a AppService) SyncAppListFromRemote() (err error) {
if err != nil { if err != nil {
return err return err
} }
defer iconRes.Body.Close()
body, err := io.ReadAll(iconRes.Body) body, err := io.ReadAll(iconRes.Body)
if err != nil { if err != nil {
return err 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.Icon = iconStr
app.TagsKey = l.AppProperty.Tags app.TagsKey = l.AppProperty.Tags
if l.AppProperty.Recommend > 0 { if l.AppProperty.Recommend > 0 {

4
backend/cron/cron.go

@ -1,6 +1,8 @@
package cron package cron
import ( import (
"fmt"
mathRand "math/rand"
"time" "time"
"github.com/1Panel-dev/1Panel/backend/app/model" "github.com/1Panel-dev/1Panel/backend/app/model"
@ -41,7 +43,7 @@ func Run() {
if _, err := global.Cron.AddJob("@daily", job.NewSSLJob()); err != nil { if _, err := global.Cron.AddJob("@daily", job.NewSSLJob()); err != nil {
global.LOG.Errorf("can not add ssl corn job: %s", err.Error()) 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()) global.LOG.Errorf("can not add appstore corn job: %s", err.Error())
} }

3
backend/middleware/demo_handle.go

@ -27,6 +27,9 @@ var whiteUrlList = map[string]struct{}{
"/api/v1/databases/variables": {}, "/api/v1/databases/variables": {},
"/api/v1/databases/status": {}, "/api/v1/databases/status": {},
"/api/v1/databases/baseinfo": {}, "/api/v1/databases/baseinfo": {},
"/api/v1/waf/attack/stat": {},
"/api/v1/waf/config/website": {},
} }
func DemoHandle() gin.HandlerFunc { func DemoHandle() gin.HandlerFunc {

Loading…
Cancel
Save