Ver Fonte

兼容申万系统缩略图

kobe6258 há 1 dia atrás
pai
commit
76c53690a3
1 ficheiros alterados com 14 adições e 1 exclusões
  1. 14 1
      controllers/data_manage/edb_info.go

+ 14 - 1
controllers/data_manage/edb_info.go

@@ -21,6 +21,7 @@ import (
 	etaTrialService "eta/eta_api/services/eta_trial"
 	"eta/eta_api/utils"
 	"fmt"
+	"regexp"
 	"sort"
 	"strconv"
 	"strings"
@@ -6745,13 +6746,25 @@ func (this *EdbInfoController) ChartImageSetBySvg() {
 		br.Ret = 408
 		return
 	}
-
+	picType := this.GetString("PicType")
 	imgData := this.GetString("Img")
 	if imgData == "" {
 		br.Msg = "图片参数错误"
 		br.ErrMsg = "图片参数错误,Img Is Empty"
 		return
 	}
+	if strings.ToLower(picType) == "png" {
+		b, _ := regexp.MatchString(`^data:\s*image\/(\w+);base64,`, imgData)
+		if !b {
+			br.Msg = "图片格式不正确"
+			br.ErrMsg = "图片格式不正确"
+			return
+		}
+		re, _ := regexp.Compile(`^data:\s*image\/(\w+);base64,`)
+		base64Str := re.ReplaceAllString(imgData, "")
+		base64Str = strings.Replace(base64Str, " ", "", -1)
+		imgData = base64Str
+	}
 	edbInfoId, _ := this.GetInt("EdbInfoId", 0)
 	if edbInfoId <= 0 {
 		br.Msg = "指标参数错误"