作者 yangfu

文章编辑修改

... ... @@ -102,7 +102,7 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) {
//设置内容概要
// 截取内容 50个字
stringIndex := 0 //字符串长度
length := 0 //字符串长度
content := ""
for i := range sectionList {
str := strings.TrimSpace(sectionList[i].Content)
... ... @@ -111,11 +111,12 @@ func (m *Article) SetSummary(sectionList []*ArticleSection) {
break
}
}
stringIndex = len(content)
if len(content) > 50 {
stringIndex = 50
runeContent := []rune(content)
length = len(runeContent)
if length > 50 {
length = 50
}
m.Summary = content[0:stringIndex]
m.Summary = string(runeContent[0:length])
}
func (m *Article) WhoCanRead(userId int64) bool {
... ...