浏览代码

no message

xingzai 10 月之前
父节点
当前提交
3a80fd437c
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7 2
      services/article.go

+ 7 - 2
services/article.go

@@ -508,8 +508,13 @@ func YxArticleAnnotation(article *models.HomeArticle) (annotation string) {
 		plus = 12
 	}
 	endIndex := strings.Index(body, "<hr")
-	if coreIndex != -1 && endIndex != -1 {
-		body = body[coreIndex+plus : endIndex]
+	//如果有下划线跟核心观点就获取 核心观点~下划线之间的内容,如果没有就获取整个下划线的内容
+	if endIndex != -1 {
+		if coreIndex != -1 {
+			body = body[coreIndex+plus : endIndex]
+		} else {
+			body = body[0:endIndex]
+		}
 	}
 	annotation = body
 	return