mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-06-28 15:45:35 +08:00
perf:优化部分代码
This commit is contained in:
parent
42dbe12f6b
commit
9f73286115
@ -63,9 +63,7 @@ func (c *DocumentController) Index() {
|
|||||||
if bookResult.IsUseFirstDocument {
|
if bookResult.IsUseFirstDocument {
|
||||||
doc, err := bookResult.FindFirstDocumentByBookId(bookResult.BookId)
|
doc, err := bookResult.FindFirstDocumentByBookId(bookResult.BookId)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if strings.TrimSpace(doc.Release) != "" {
|
doc.AppendInfo()
|
||||||
doc.Release += "<div class=\"wiki-bottom\">文档更新时间: " + doc.ModifyTime.Local().Format("2006-01-02 15:04") + "</div>";
|
|
||||||
}
|
|
||||||
selected = doc.DocumentId
|
selected = doc.DocumentId
|
||||||
c.Data["Title"] = doc.DocumentName
|
c.Data["Title"] = doc.DocumentName
|
||||||
c.Data["Content"] = template.HTML(doc.Release)
|
c.Data["Content"] = template.HTML(doc.Release)
|
||||||
@ -179,17 +177,7 @@ func (c *DocumentController) Read() {
|
|||||||
if doc.ModifyTime != doc.CreateTime {
|
if doc.ModifyTime != doc.CreateTime {
|
||||||
docInfo += ";更新于 "
|
docInfo += ";更新于 "
|
||||||
docInfo += doc.ModifyTime.Local().Format("2006-01-02 15:04")
|
docInfo += doc.ModifyTime.Local().Format("2006-01-02 15:04")
|
||||||
if strings.TrimSpace(doc.Release) != "" {
|
doc.AppendInfo()
|
||||||
doc.Release += "<div class=\"wiki-bottom\">文档更新时间: " + doc.ModifyTime.Local().Format("2006-01-02 15:04") + " 作者:";
|
|
||||||
if docCreator != nil {
|
|
||||||
if docCreator.RealName != "" {
|
|
||||||
doc.Release += docCreator.RealName
|
|
||||||
} else {
|
|
||||||
doc.Release += docCreator.Account
|
|
||||||
}
|
|
||||||
}
|
|
||||||
doc.Release += "</div>"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.IsAjax() {
|
if c.IsAjax() {
|
||||||
|
@ -298,4 +298,23 @@ func (item *Document) ReleaseContent() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//追加一些文档信息.
|
||||||
|
func (doc *Document) AppendInfo() *Document {
|
||||||
|
|
||||||
|
docCreator, err := NewMember().Find(doc.MemberId,"real_name","account")
|
||||||
|
|
||||||
|
if strings.TrimSpace(doc.Release) != "" {
|
||||||
|
doc.Release += "<div class=\"wiki-bottom\">文档更新时间: " + doc.ModifyTime.Local().Format("2006-01-02 15:04") + " 作者:";
|
||||||
|
if err == nil && docCreator != nil {
|
||||||
|
if docCreator.RealName != "" {
|
||||||
|
doc.Release += docCreator.RealName
|
||||||
|
} else {
|
||||||
|
doc.Release += docCreator.Account
|
||||||
|
}
|
||||||
|
}
|
||||||
|
doc.Release += "</div>"
|
||||||
|
}
|
||||||
|
return doc
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user