Prechádzať zdrojové kódy

wip:判断是否移动端

fuwencai 7 mesiacov pred
rodič
commit
4b9e919a8c
1 zmenil súbory, kde vykonal 2 pridanie a 2 odobranie
  1. 2 2
      src/service/action/copywritingConfig.go

+ 2 - 2
src/service/action/copywritingConfig.go

@@ -23,13 +23,13 @@ type RequestMsg struct {
 	Codes []string `json:"codes"` // 留资source
 }
 
-var mobileUrl = regexp.MustCompile("(?i)(app|H5|h5|ios)")
+var mobileReg = regexp.MustCompile("(?i)(Android|Mobile|Phone)")
 
 func (c *Config) GetConfig() {
 	defer common.Catch()
 	reqMsg := new(RequestMsg)
 	if json.Unmarshal(c.Body(), &reqMsg) == nil && len(reqMsg.Codes) > 0 {
-		bm := mobileUrl.MatchString(c.Request.Referer()) || mobileUrl.MatchString(c.Request.Host)
+		bm := mobileReg.MatchString(c.Header("User-Agent"))
 		codes := entity.GetConfig(reqMsg.Codes, bm)
 		c.ServeJson(api.Result{Data: codes})
 		return