Bläddra i källkod

feat:正文截取3

wangchuanjin 10 månader sedan
förälder
incheckning
41d83dae97
1 ändrade filer med 10 tillägg och 8 borttagningar
  1. 10 8
      jyBXSubscribe/rpc/model/push.go

+ 10 - 8
jyBXSubscribe/rpc/model/push.go

@@ -308,15 +308,17 @@ func subStrDetail(matchKey, detail string) string {
 		matchKeys = append(matchKeys, regexp.QuoteMeta(v))
 	}
 	if len(matchKeys) > 0 {
-		indexs := regexp.MustCompile(strings.Join(matchKeys, "|")).FindStringIndex(detail)
-		if len(indexs) > 0 {
-			start := string(detail[0:indexs[0]])
-			if len([]rune(start)) > 50 {
-				start = string([]rune(start)[len([]rune(start))-50:])
-			}
-			detail = start + string(detail[indexs[0]:])
-		}
+		return ""
+	}
+	indexs := regexp.MustCompile(strings.Join(matchKeys, "|")).FindStringIndex(detail)
+	if len(indexs) == 0 {
+		return ""
+	}
+	start := string(detail[0:indexs[0]])
+	if len([]rune(start)) > 50 {
+		start = string([]rune(start)[len([]rune(start))-50:])
 	}
+	detail = start + string(detail[indexs[0]:])
 	if len([]rune(detail)) > 200 {
 		detail = string([]rune(detail)[:200])
 	}